//Question3.cpp // This program finds the average time spent programming by a student // each day over...
Question:
//Question3.cpp
// This program finds the average time spent programming by a student
// each day over a three day period.
#include
using namespace std;
int main()
{
int n;
int numStudents;
float numHours, total, average;
int student, day = 0; // these are the counters for the loop
cout << "This program will find the average number of hours a day"
<< " that a student spent programming over a long weekend";
cout << "How many students are there?" << endl << endl;
cin >> numStudents;
for(student = 1; student <= numStudents; student++)
{
total = 0;
for( day = 1; day <= 3; day++)
{
cout << "Please enter the number of hours worked by student"
<< student <<" on day " << n << "." << endl;
cin >> numHours;
total = total + numHours;
}
average = total/3;
cout << endl;
cout << "The average number of hours per day spent programming "
<< "by student " << student << " is " << average
<< endl << endl << endl;
}
return 0;
}
!. The outer loop controls the number of students. Inner loop is always executed three times, once for each day of the long weekend. Modify the code so that the inner loop iterates n times, where n is positive integer that the user inputs.Thus, the users decide how many days to consider just as they choose how many students to consider.
2. Modify so that it also finds the average number of hours per day that a given student studies biology as well as programming. For each given student include two prompts, one for each subject. Have the program display which subject the student, on average, spend most time on.