If Function

New to programming and I'm my best to understand, the book is little to no help.
Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Design the following functions in the program:

determineGrade—This function should accept a test score as an argument and return a letter grade for the score (as a String), based on the following grading scale:

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
//Declare Integer test1, test2, test3, test4, test5
//Declare String score1, score2, score3, score4, score5
//Declare Integer average
//Declare String Finalgrade
//Declare String determineGrade

cout << "Please enter your score for Test 1.";
cin >> Test1
Set score1 = determineGrade (test1);
cout << "Your letter grade for Test 1 is" , score1
cout << "Please enter your score for Test 2."
cin>> test2
Set score2 = determineGrade (test2)
cout << "Your letter grade for Test 2 is" , score2
cout << "Please enter your score for Test 3."
cin>> test3
Set score3 = determineGrade (test3)
cout << "Your letter grade for Text 3 is" , score3
cout << "Please enter your score for Test 4."
cin>> test4
Set score4 = determineGrade (test4)
cout << "Your letter grade for Test 4 is" , score4
cout << "Please enter your score for Test 5."
cin>> test5
Set score5 = determineGrade (test5)
cout << "Your letter grade for Test 5 is" , score5
Set average = calcAverage (test1,test2,test3,test4,test5)
cout << "The average test score you made on all five are" , average
Set Finalgrade = determineGrade (average)
cout << "The average letter grade you have made is" , Finalgrade
End Module

system("PAUSE");
return EXIT_SUCCESS;
}
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
#include <iostream>

using namespace std;
int main()
{
	int Score[5];

	for (int i = 0; i < 5; ++i)
	{
		printf("Enter Score %d: ", i);
		cin >> Score[i];
	}
	for (int i = 0; i < 5; ++i)
	{
		if (Score[i] >= 90)
			printf("Grade %d: A\n", i);
		if (Score[i] >= 80 && Score[i] < 90)
			printf("Grade %d: B\n", i);
		if (Score[i] >= 76 && Score[i] < 80)
			printf("Grade %d: C\n", i);
		if (Score[i] >= 70 && Score[i] <= 75)
			printf("Grade %d: D\n", i);
		if (Score[i] < 70)
			printf("Grade %d: F\n", i);
	}
	system("pause");
	return 0;
}
Topic archived. No new replies allowed.