Text
//MAHIANAN; A19EC4050;
#include <iostream>
#include<conio.h>
using namespace std;
double getAVG (double);
int main ()
{
int TOTAL_HOUR;
double averageAll;
struct Subject
{
string name;
char code [10];
int credit;
};
struct Tutor{
int hourperweek;
Subject subjectname;
string name;
};
//getting input of Tutor name, hourperweek of type integer and subjectname of type struct Subject.
Tutor A[4];
for (int i = 0; i < 4; i++)
{
cout << "Tutor - " << i + 1 <<endl;
cout << "ENTER TUTOR'S NAME': "<<endl;
cin >> A[i].name;
cout << "ENTER TUTOR'S WORKING TIME': "<<endl;
cin >> A[i].hourperweek;
cout << "ENTER SUBJECT NAME: "<<endl;
cin >> A[i].subjectname.name;
cout << "ENTER SUBJECT CODE: "<<endl;
cin >> A[i].subjectname.code;
cout << "ENTER SUBJECT CREDIT: "<<endl;
cin >> A[i].subjectname.credit;
cout << endl << "TUTOR'S INFORMATION'.... "<<endl;
cout << endl << A[i].name << " " << A[i].hourperweek << " " << A[i].subjectname.name << " " << A[i].subjectname.code << " " << A[i].subjectname.credit << endl << endl;
TOTAL_HOUR += A[i].hourperweek;
}
averageAll = getAVG (TOTAL_HOUR);
}
double getAVG (double TOTAL_HOUR)
{
double averageAll;
averageAll = TOTAL_HOUR/4;
cout << "Average of hour per week for all tutors: " << averageAll << endl;
}