i am very greatful for this site because i know my question will be answered at last. i have been trying to loop a program for a long time. but it seems the loop doesnt work. the program works fine without loops but anytime i insert the loop, the program terminates incorrectly. i have been lean from the book "learn to program with c++" by john smiley. this is the source code:
else
if(finalNumericGrade < 70)
finalLetterGrade = 'F';
cout << endl << "***ENGLISH STUDENT***" << endl;
cout << "Midterm grade is: " << midterm << endl;
cout << "Final Exam Grade is: " << finalExamGrade << endl;
cout << "Research grade is : " << research << endl;
cout << "Presentation grade is: " << presentation << endl << endl;
cout << "Final Numeric Grade is: " << finalNumericGrade << endl;
cout << "Final Letter Grade is: " << finalLetterGrade << endl;
break;
//Case 2 is a Math Student
case 2:
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);
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 << " ***MATH STUDENT***" << endl << endl;
cout << "Midterm grade is: " << endl;
cout << "Final Exam is: " << finalExamGrade << endl;
cout << "Final Numeric Grade is: " << finalNumericGrade << endl;
cout << "Final Letter Grade is: " << finalLetterGrade;
break;
//Case 3 is a Science Student
case 3:
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 Research Grade: ";
cin.getline(response,256);
research = atoi(response);
else
if ((finalNumericGrade >=80) & (finalNumericGrade <90))
finalLetterGrade = 'B';
else
if ((finalNumericGrade >=70) & (finalNumericGrade <80))
finalLetterGrade = 'C';
else
if ((finalNumericGrade >=60) & (finalNumericGrade <70))
finalLetterGrade = 'D';
else
if (finalNumericGrade <60)
finalLetterGrade = 'F';
cout << endl << "***SCIENCE STUDENT***" << endl << endl;
cout << "Midterm grade is: " << midterm << endl;
cout << "Final Exam Grade is: " << finalExamGrade << endl;
cout << "Research grade is: " << research << 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 << endl << endl << "Do you have another grade to calculate? ";
cin >> moreGradesToCalculate;
for (int i = 0; i < moreGradesToCalculate.length(); i++) {
moreGradesToCalculate[i] = toupper (moreGradesToCalculate[i]);
}
}
cout << "Thanks for using the Grades Calculation Program!";
system ("pause");
return 0;
} // end of main
i am looking forward to getting an answer soon. thanks in advance