Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- double quiz1, quiz2, quiz3, quiz4, quiz5,
- average;
- for (; ;) {
- cout << "Enter 5 quiz scores with values in between 0-100 to find the average\nScore 1: ";
- cin >> quiz1;
- cout << "Score 2: ";
- cin >> quiz2;
- cout << "Score 3: ";
- cin >> quiz3;
- cout << "Score 4: ";
- cin >> quiz4;
- cout << "Score 5: ";
- cin >> quiz5;
- if (quiz1 < 0 || quiz1 > 100 || quiz2 < 0 || quiz2 > 100 || quiz3 < 0 || quiz3 > 100 || quiz4 < 0 || quiz4 > 100 || quiz5 < 0 || quiz5 > 100)
- {
- cout << "Error, all inputs must be 1-100";
- break;
- }
- else {
- average = (quiz1 + quiz2 + quiz3 + quiz4 + quiz5) / 5;
- cout << "The average of these 5 scores is " << average << ".";
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement