Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- char initial = 'a';
- double aStu = 0, bStu = 0, cStu = 0, dStu = 0, fStu = 0, grade = 0, totGrade = 0, avgGrade = 0, totStu = 0;
- while (initial != 'Z') {
- printf("Please enter your initial ('Z' to quit): ");
- scanf("%c", &initial);
- getchar();
- printf("%c, please enter your numeric grade: ", initial);
- scanf_s("%lf", &grade);
- if (grade <= 100 && grade >= 90) {
- aStu++;
- totStu++;
- totGrade = (grade + totGrade);
- printf("%c, you got a A.\n", initial);
- }
- else if (grade < 90 && grade >= 80) {
- bStu++;
- totStu++;
- totGrade = (grade + totGrade);
- printf("%c, you got a B.\n", initial);
- }
- else if (grade < 80 && grade >= 70) {
- cStu++;
- totStu++;
- totGrade = (grade + totGrade);
- printf("%c, you got a C.\n", initial);
- }
- else if (grade < 70 && grade >= 60) {
- dStu++;
- totStu++;
- totGrade = (grade + totGrade);
- printf("%c, you got a D.\n", initial);
- }
- else if (grade < 60 && grade >= 0) {
- fStu++;
- totStu++;
- totGrade = (grade + totGrade);
- printf("%c, you got a F.\n", initial);
- }
- else if (grade > 100 || grade < 0); {
- printf("%c, that is an invalid grade.\n", initial);
- }
- }
- printf("You entered %.0lf students.\n", totStu);
- printf("The average numeric grade for the class is: %.0lf\n", avgGrade);
- printf("There were %.0lf A's.\n", aStu);
- printf("There were %.0lf B's.\n", bStu);
- printf("There were %.0lf C's.\n", cStu);
- printf("There were %.0lf D's.\n", dStu);
- printf("There were %.0lf F's.\n", fStu);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement