Hello I am having more trouble with programming this one is with structures.
I need to Write a program which uses a structure having the indicated member names to store the following data:
Name (student name)
IDnum (student ID number)
Tests (an array of three test scores)
Average (average test score)
Grade (course grade)
The program will keep a list of three test scores for one student. The program may prompt the user for the name, ID number, and test scores, or these may be assigned within the program. The average test score will be calculated and stored in the average member of the structure. The course grade will be assigned based on this scale:
A 91 - 100
B 81 - 90
C 71 - 80
D 61 - 70
F 0 - 60
Store the course grade in the Grade member of the structure. Display the student name, ID, average test score, and course grade on the screen.
This is what I have so far but the output is always 122.
// ConsoleApplication10.cpp : Defines the entry point for the console application.
//
// ConsoleApplication10.cpp : Defines the entry point for the console application.
//
//#include "stdafx.h"
#include <iostream>
#include <string>
usingnamespace std;
struct Grades
{
string name;//Student's name
int studentID; //Student's Identification Number
double test [3];
double average;
char grade;
};
/* You can declare a array of structs like this :
Grades variable_name[array_size]; and access it with variable_name[index].member.
Example Grades details[4]; details[n].name;
Check your functions and where and when you call them.
*/
// Function Prototypes.
int GetGrades(int, int, int);
int FindAverage(int, int);
int main()
{
Grades student;
Grades grd;
//Get Student name
cout << "Enter the Student name :";
cin.ignore();
getline(cin, grd.name);
//Get Student's ID
cout << "Enter the Student's Identification Number: ";
cin >> student.studentID;
//Get scores
cout << "Enter three test scores: ";
}
int grade()/* Try making this return a char of letterGrade instead of a int of zero and accept a variable of sum scores*/
{
constint numberOfGrades = 3;
int /*numberOfGrades,*/ letterGrade;
int totalPoints, average;
GetGrades(numberOfGrades, totalPoints, average); /* You are trying to call a function thats doesn't exist in the code*/
while (totalPoints >= 0)
{
if (totalPoints >= 90 && totalPoints == 100) // 90 and above
letterGrade = 'A';
elseif (totalPoints >= 80 && totalPoints == 89) //80-89
letterGrade = 'B';
elseif (totalPoints >= 70 && totalPoints == 79) //70-79
letterGrade = 'C';
elseif (totalPoints >= 60 && totalPoints == 69) //60-69
letterGrade = 'D';
elseif (totalPoints >= 0 && totalPoints == 59) //0-59
letterGrade = 'F';
}
return 0;
}
int FindAverage(int numericGrade, int numberOfGrades)
{
/* Display the average(to what or where)*/
return (numericGrade) / numberOfGrades;
}