Advertisement
Guest User

Untitled

a guest
Aug 9th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. int main()
  2. {
  3. char initial = 'a';
  4. double aStu = 0, bStu = 0, cStu = 0, dStu = 0, fStu = 0, grade = 0, totGrade = 0, avgGrade = 0, totStu = 0;
  5.  
  6. while (initial != 'Z') {
  7. printf("Please enter your initial ('Z' to quit): ");
  8. scanf("%c", &initial);
  9. getchar();
  10. printf("%c, please enter your numeric grade: ", initial);
  11. scanf_s("%lf", &grade);
  12. if (grade <= 100 && grade >= 90) {
  13. aStu++;
  14. totStu++;
  15. totGrade = (grade + totGrade);
  16. printf("%c, you got a A.\n", initial);
  17. }
  18. else if (grade < 90 && grade >= 80) {
  19. bStu++;
  20. totStu++;
  21. totGrade = (grade + totGrade);
  22. printf("%c, you got a B.\n", initial);
  23. }
  24. else if (grade < 80 && grade >= 70) {
  25. cStu++;
  26. totStu++;
  27. totGrade = (grade + totGrade);
  28. printf("%c, you got a C.\n", initial);
  29. }
  30. else if (grade < 70 && grade >= 60) {
  31. dStu++;
  32. totStu++;
  33. totGrade = (grade + totGrade);
  34. printf("%c, you got a D.\n", initial);
  35. }
  36. else if (grade < 60 && grade >= 0) {
  37. fStu++;
  38. totStu++;
  39. totGrade = (grade + totGrade);
  40. printf("%c, you got a F.\n", initial);
  41. }
  42. else if (grade > 100 || grade < 0); {
  43. printf("%c, that is an invalid grade.\n", initial);
  44. }
  45. }
  46.  
  47.  
  48.  
  49. printf("You entered %.0lf students.\n", totStu);
  50. printf("The average numeric grade for the class is: %.0lf\n", avgGrade);
  51. printf("There were %.0lf A's.\n", aStu);
  52. printf("There were %.0lf B's.\n", bStu);
  53. printf("There were %.0lf C's.\n", cStu);
  54. printf("There were %.0lf D's.\n", dStu);
  55. printf("There were %.0lf F's.\n", fStu);
  56.  
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement