Answer to Question #317965 in C++ for jane

Question #317965

Les assume you create a system which asks the user for the number of students and the

number of test scores per student. A nested inner loop, should ask for all the test scores for one

student, iterating once for each test score. The outer loop should iterate once for each student

and take student name as input. After taking input for 3 test scores, calculate average for each

student. Take 3 test scores and 4 students.

Note: use do-while loops


1
Expert's answer
2022-03-25T12:10:00-0400
#include <iostream>
#include <iomanip>
using namespace std;


int main() {
    const int NUM_STUDENTS = 4;
    const int NUM_TESTS = 3;


    int num_student = 1;
    do {
        cout << "Enter data for the " << num_student << "th student" << endl;


        int sum = 0;
        int num_test = 1;
        do {
            int score;
            cout << "Test " << num_test << ": ";
            cin >> score;
            sum += score;
            num_test++;
        } while (num_test <= NUM_TESTS);


        double avg = sum / NUM_TESTS;
        cout << "Average score is "
             << fixed << setprecision(2) << avg << endl << endl;


        num_student++;
    } while (num_student <= NUM_STUDENTS);


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog