Write a program which uses a structure having the indicated member names to store the following data:
Question:
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
// 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 ID Number
double test[3];
double average;
char grade;
};
// Function Prototypes.
int GetGrades(int, int, int);
int FindAverage(int, int);
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 ID Number: ";
cin >> student.studentID;
//Get scores
cout << "Enter three test scores: ";
}
int grade()
{
const int numberOfGrades = 3;
int /*numberOfGrades,*/ letterGrade;
int totalPoints, average;
GetGrades(numberOfGrades, totalPoints, average);
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;
}
Database Systems A Practical Approach to Design Implementation and Management
ISBN: 978-0132943260
6th Edition Global
Authors: Thomas Connolly, Carolyn Begg