I do not think I am understanding the instructions given to me in the first place. The instructions look convoluted and messy to me. My teacher makes no sense and allows no questions.
-Write a program that prompts a user for their grades, finds the average and prints out a letter grade.
-The program calls a function called GetGrades that will read in grades from the keyboard, the number of grades should also be input by the user.
-GetGrades will find the sum of those grades and pass the sum and number of grades to another function called FindAverage.
-FindAverage will find the average of the grades and return this average to GetGrades.
-GetGrades will return this average to main.
-The main function will then determine the letter grade of that average based on a 10-point scale and print out this grade.
-Main should determain the letter grade of an average based on a 10-point scale and print out this grade.
90–100 A
80–89 B
70–79 C
60–69 D
0–59 F
-GetGrades function should get number of grades, read the grades entered, find the sum of those grades and pass the sum and number to FindAverage.
-FindAverage will get the average of the grades and return the average to GetGrades.
-GetGrades will return this average to main.
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
|
#include <iostream>
using namespace std;
// Function Prototypes.
int GetGrades(int,int,int);
int FindAverage(int,int);
int main()// Determine letter grade of the average.
{
int numberOfGrades, letterGrade;
int totalPoints, average;
GetGrades(numberOfGrades,numericGrade,average); // Call GetGrades
while (totalPoints >= 0)
{
if (totalPoints >= 90 && totalPoints ==100) // 90 and above
letterGrade = 'A';
else if (totalPoints >= 80 && totalPoints== 100) //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';
cout << "Total Score: " << totalPoints << endl;
cout << "Grade: " << letterGrade << endl;
}
return 0;
}
int GetGrades(int numberOfGrades,int numericGrade, int average)
{
// Get number of grades.
cout << "How many grades would you like to enter? " << endl;
cin >> numberOfGrades;
// Read the grades entered by user.
for (int i = 0;i > numberOfGrades; i++)
{
cout << "Please enter a numeric grade: "<< endl;
cin >> numericGrade;
}
// Call Function.
return FindAverage(numericGrade, numberOfGrades);
cout << "The average of the numeric grades you entered is: " << average << endl;
}
int FindAverage(int numericGrade,int numberOfGrades)
{
// Display the average.
return (numericGrade)/numberOfGrades;
}
|