class program for grades need help please

1. Write a grading program for a class with the following grading policies:

a. There are two quizzes, each graded on the basis of 10 points.
b. There is one midterm exam and one final exam, each graded on the basis of 100 points.
c. The final exam counts for 50% of the grade, the midterm counts for 25%, and the two quizzes together count for a total of 25%. this is what i have so far but when run in cpp.sh i am getting
Would you like to calculate a grade? yes
when i type in yes
it does not allow me to add the grades i am stuck all i get after yes is
Enter student type (1=English, 2=Math, 3=Science): You must select a Student Type
i seem to be stuck I am new to c++ so i do not know where i am wrong the book is no help that is for sure.
please any feedback would be useful and appreciated Thank you in advanced

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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
  #include <iostream>
#include <cstring>
using namespace std;

// this program will give the quiz, mid term, final grade
int main(){
	const float ENGLISH_MIDTERM_PERCENTAGE = .50;
	const float ENGLISH_FINALEXAM_PERCENTAGE = .50;
	const float ENGLISH_QUIZ = .10;
	const float MATH_MIDTERM_PERCENTAGE = .50;
	const float MATH_FINALEXAM_PERCENTAGE = .50;
	const float MATH_QUIZ = .10;
	int midterm = 0;
	int finalExamGrade = 0;
	int quiz = 0;
	float finalNumericGrade = 0;
    string finalLetterGrade;
	char response[256];
	string moreGradesToCalculate;

	cout << "Would you like to calculate a grade? ";
	cin >> moreGradesToCalculate;

	for (unsigned int i = 0; i < moreGradesToCalculate.length(); i++){
		moreGradesToCalculate[i] = toupper(moreGradesToCalculate[i]);
	}

	while (moreGradesToCalculate == "YES"){

	//What type of student are we calculating?
	cout << "Enter student type (1=English, 2=Math, 3=Science): "; 
	cin.getline(response,256);

	if (strlen(response) == 0){
		cout << "You must select a Student Type";
	
		return 1;
	}

	if ((atoi(response) < 1) || (atoi(response) > 3)){
		cout << response << " - is not a valid Student Type.";
		
		return 1;
	}

	//Student Type is valid, now let's calculate the grade
	switch(atoi(response)){
	//Case 1 is English Student
	case 1:
		cout << "Enter the Midterm Grade: ";
		cin.getline(response,256);
		midterm = atoi(response);
		cout << "Enter the Final Examination Grade: ";
		cin.getline(response,256);
		finalExamGrade = atoi(response);
		cout << "Enter the quiz Grade: ";
		cin.getline(response,256);
		quiz = atoi(response);
		finalNumericGrade = (midterm * ENGLISH_MIDTERM_PERCENTAGE) + 
							(finalExamGrade * ENGLISH_FINALEXAM_PERCENTAGE) + 
							(quiz * ENGLISH_QUIZ);
							
		if (finalNumericGrade >= 93)
			finalLetterGrade = 'A';
		else if ((finalNumericGrade >= 85) && (finalNumericGrade < 93))
			finalLetterGrade = 'B';
		else if ((finalNumericGrade >= 78) && (finalNumericGrade < 85))
			finalLetterGrade = 'C';
		else if ((finalNumericGrade >= 70) && (finalNumericGrade < 78))
			finalLetterGrade = 'D';
		else if (finalNumericGrade < 70)
			finalLetterGrade = 'F';
		cout << endl;
		cout << "*** ENGLISH STUDENT ***" << endl << endl;
		cout << "Midterm grade is: " << midterm << endl;
		cout << "Final grade is: " << finalExamGrade << endl;
		cout << "quiz grade is: " << quiz << endl;
		cout << "Final Numeric Grade is: " << finalNumericGrade << endl;
		cout << "Final Letter Grade is: " << finalLetterGrade;
		break;
	//Case 2 is Math Student
	case 2:
		cout << "Enter Midterm grade: ";
		cin.getline(response,256);
		midterm = atoi(response);
		cout << "Enter Final Exam grade: ";
		cin.getline(response,256);
		finalExamGrade = atoi(response);
		cout << "Enter the quiz Grade: ";
		cin.getline(response,256);
		quiz = atoi(response);
		finalNumericGrade = (midterm * MATH_MIDTERM_PERCENTAGE) + 
							(finalExamGrade * MATH_FINALEXAM_PERCENTAGE) +
							(quiz * MATH_QUIZ);
		if (finalNumericGrade > 90)
			finalLetterGrade = 'A';
		else if ((finalNumericGrade >= 83) && (finalNumericGrade < 90))
			finalLetterGrade = 'B';
		else if ((finalNumericGrade >= 76) && (finalNumericGrade < 83))
			finalLetterGrade = 'C';
		else if ((finalNumericGrade >= 65) && (finalNumericGrade < 76))
			finalLetterGrade = 'D';
		else if (finalNumericGrade < 65)
			finalLetterGrade = 'F';
		cout << endl;
		cout << "*** MATH STUDENT ***" << endl << endl;
		cout << "Midterm grade is: " << midterm << endl;
		cout << "Final grade is: " << finalExamGrade << endl;
		cout << "quiz grade is: " << quiz << endl;
		cout << "Final Numeric Grade is: " << finalNumericGrade << endl;
		cout << "Final Letter Grade is: " << finalLetterGrade;
		break;
	
	default:
		cout << response << " - is not a valid Student Type.";
		return 1;
	}					//End of Switch

	cout << "Grade another student? ";
	cin >> moreGradesToCalculate;

	for (unsigned int i = 0; i < moreGradesToCalculate.length(); i++){
		moreGradesToCalculate[i] = toupper(moreGradesToCalculate[i]);
	}						   //End for loop

	}                         

	return 0; //end of main()
}
1
2
3
cin >> moreGradesToCalculate;
//...
cin.getline(response,256);
http://stackoverflow.com/questions/21567291/why-does-stdgetline-skip-input-after-a-formatted-extraction

Why not use std::string for response? You already using it in your program. Actually, why not use correct data type (int) in the beginning?
Topic archived. No new replies allowed.