New Project

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.
//

#include "stdafx.h"
#include <iostream>
#include <string>


using namespace std;


struct Grades
{
string name;//Student's name
int studentID; //Student's Identification Number
double test [3];
double average;
char grade;

};

// 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()// Determine letter grade of the average.
{
const int numberOfGrades = 3;

int numberOfGrades, letterGrade;
int totalPoints, average;

GetGrades(numberOfGrades, totalPoints, average); // Call GetGrades

while (totalPoints >= 0)
{
if (totalPoints >= 90 && totalPoints == 100) // 90 and above
letterGrade = 'A';
else if (totalPoints >= 80 && totalPoints == 89) //80-89
letterGrade = 'B';
else if (totalPoints >= 70 && totalPoints == 79) //70-79
letterGrade = 'C';
else if (totalPoints >= 60 && totalPoints == 69) //60-69
letterGrade = 'D';
else if (totalPoints >= 0 && totalPoints == 59) //0-59
letterGrade = 'F';

}
return 0;
}


int FindAverage(int numericGrade, int numberOfGrades)
{
// Display the average.
return (numericGrade) / numberOfGrades;
}







Last edited on
The biggest thing I need assistance with is using a structure to get an array that is entered and using the information to come up with the average
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// ConsoleApplication10.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <iostream>
#include <string>


using namespace 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*/
{
const int 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';
else if (totalPoints >= 80 && totalPoints == 89) //80-89
letterGrade = 'B';
else if (totalPoints >= 70 && totalPoints == 79) //70-79
letterGrade = 'C';
else if (totalPoints >= 60 && totalPoints == 69) //60-69
letterGrade = 'D';
else if (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;
}
Topic archived. No new replies allowed.