Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main () {
  5. int ip = -1;
  6. int tot = 0;
  7. int num = 0;
  8. int outstanding_scores = 0;
  9. int satisfactory_scores = 0;
  10. int unsatisfactory_scores= 0;
  11. char answer = 'Y';
  12. //bool valid = true;
  13.  
  14.  
  15. while ((answer=='Y') || (answer=='y')){
  16.  
  17. cout << "Input score:";
  18. cin >> ip;
  19.  
  20. if (cin.good()) {
  21.  
  22. if (ip >= 0) {
  23. if((ip>=90)&&(ip<=100)){
  24. outstanding_scores++;
  25. cout << "Outstanding score! ";
  26. }
  27. else if((ip>=60)&&(ip<=89)){
  28. satisfactory_scores++;
  29. cout << "Satisfactory score. ";
  30. }
  31. else if(ip<=59){
  32. unsatisfactory_scores++;
  33. cout << "Unsatisfactory score. ";
  34. }
  35. else {
  36. cout << "Invalid score. ";
  37. }
  38. tot = tot + ip;
  39. num++;
  40. cout << "Would you like to enter another exam?";
  41. cin >> answer;
  42.  
  43. }
  44. else {
  45. cout << "Integer is not greater than zero. ";
  46. }
  47. }
  48. else {
  49. cout << "You did not enter an Integer. ";
  50. }
  51. }
  52. cout << "The average scores of these exams are " << tot/num;
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement