Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a complete C++ program to input 3 integer scores, and output the real aver

ID: 3885254 • Letter: W

Question

Write a complete C++ program to input 3 integer scores, and output the real average.

, if the scores are 90, 79, and 88, the output from your program should be

Average: 85.6667

followed by a newline. However, it is possible that one or more of the scores is invalid, in which case the program should output "invalid data!" followed by a newline. Note that it is possible for multiple scores to be invalid --- your program should output "invalid data!" exactly once. A score is invalid if it is less than 0 or greater than 100.

Explanation / Answer

#include<iostream>

using namespace std;

int main(){

     int n1,n2,n3;

     cout << "Enter 3 scores :";
     cin >> n1 >> n2 >> n3;

     if ((n1<0 || n1 > 100) || (n2<0 || n2 > 100) || (n3<0 || n3 > 100)){
         cout << "Invalid Input ";
     }
     else {
         double avg = (n1+n2+n3)/3.0;
         cout << "Average : " << avg << endl;
     }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote