Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. int main()
  2. {
  3. double quiz1, quiz2, quiz3, quiz4, quiz5,
  4. average;
  5.  
  6. for (; ;) {
  7. cout << "Enter 5 quiz scores with values in between 0-100 to find the average\nScore 1: ";
  8. cin >> quiz1;
  9. cout << "Score 2: ";
  10. cin >> quiz2;
  11. cout << "Score 3: ";
  12. cin >> quiz3;
  13. cout << "Score 4: ";
  14. cin >> quiz4;
  15. cout << "Score 5: ";
  16. cin >> quiz5;
  17.  
  18. if (quiz1 < 0 || quiz1 > 100 || quiz2 < 0 || quiz2 > 100 || quiz3 < 0 || quiz3 > 100 || quiz4 < 0 || quiz4 > 100 || quiz5 < 0 || quiz5 > 100)
  19. {
  20. cout << "Error, all inputs must be 1-100";
  21. break;
  22. }
  23. else {
  24. average = (quiz1 + quiz2 + quiz3 + quiz4 + quiz5) / 5;
  25. cout << "The average of these 5 scores is " << average << ".";
  26. break;
  27. }
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement