The university needs to keep a record of the students grades. I need to make a p
ID: 3776454 • Letter: T
Question
The university needs to keep a record of the students grades. I need to make a program in C++ format and language that calculated the average grade per student, per classroom and the average of the institution. There are 3 grades (0-100 integer), 2 students. and 2 classes.
It must output the following:
Classroom 1 introduce grade 1 of student 1:
Classroom 1 introduce grade 2 of student 1:
Classroom 1 introduce grade 3 of student 1:
Classroom 1 introduce grade 1 of student 2:
Classroom 1 introduce grade 2 of student 2:
Classroom 1 introduce grade 3 of student 2:
Classroom 2 introduce grade 1 of student 1:
Classroom 2 introduce grade 2 of student 1:
Classroom 2 introduce grade 3 of student 1:
Classroom 2 introduce grade 1 of student 2:
Classroom 2 introduce grade 2 of student 2:
Classroom 2 introduce grade 3 of student 2:
A triple nested loop must be used and it should output the results: average grade of student 1, average grade of student 2, average grade of class1, average grade of class2. average grade of university.
Explanation / Answer
Code:
#include<iostream>
#include <cstdlib> /* srand, rand */
#include <ctime>
#include <unistd.h>
#include <cstdio>
#include <csignal>
using namespace std;
int main()
{
int c1s1g1,c1s1g2,c1s1g3;
int c1s2g1,c1s2g2,c1s2g3;
int c2s1g1,c2s1g2,c2s1g3;
int c2s2g1,c2s2g2,c2s2g3;
cout<<"enter classroom 1 student 1 grade 1 "<<endl;
cin>>c1s1g1;
cout<<"enter classroom 1 student 1 grade 2 "<<endl;
cin>>c1s1g2;
cout<<"enter classroom 1 student 1 grade 3 "<<endl;
cin>>c1s1g3;
cout<<"enter classroom 1 student 2 grade 1 "<<endl;
cin>>c1s2g1;
cout<<"enter classroom 1 student 2 grade 2 "<<endl;
cin>>c1s2g2;
cout<<"enter classroom 1 student 2 grade 3 "<<endl;
cin>>c1s2g3;
cout<<"enter classroom 2 student 1 grade 1 "<<endl;
cin>>c2s1g1;
cout<<"enter classroom 2 student 1 grade 2 "<<endl;
cin>>c2s1g2;
cout<<"enter classroom 2 student 1 grade 3 "<<endl;
cin>>c2s1g3;
cout<<"enter classroom 2 student 2 grade 1 "<<endl;
cin>>c2s2g1;
cout<<"enter classroom 2 student 2 grade 2 "<<endl;
cin>>c2s2g2;
cout<<"enter classroom 2 student 2 grade 3 "<<endl;
cin>>c2s2g3;
float avgst1=0;
float avgst2=0;
float avgcl1=0;
float avgcl2=0;
float avggr=0;
avgst1 = (c1s1g1 + c1s1g2 + c1s1g3 + c2s1g1 + c2s1g2 + c2s1g3)/6;
avgst2 = (c1s2g1 + c1s2g2 + c1s2g3 + c2s2g1 + c2s2g2 + c2s2g3)/6;
avgcl1 = (c1s1g1 + c1s1g2 + c1s1g3 + c1s2g1 + c1s2g2 + c1s2g3)/6;
avgcl2 = (c2s1g1 + c2s1g2 + c2s1g3 + c2s2g1 + c2s2g2 + c2s2g3)/6;
avggr = (c1s1g1 + c1s1g2 + c1s1g3 + c1s2g1 + c1s2g2 + c1s2g3+c2s1g1 + c2s1g2 + c2s1g3 + c2s2g1 + c2s2g2 + c2s2g3)/12;
cout<<"average of student 1 "<<avgst1<<endl;
cout<<"average of student 2 "<<avgst2<<endl;
cout<<"average of class 1 "<<avgcl1<<endl;
cout<<"average of class 2 "<<avgcl2<<endl;
cout<<"average of university "<<avggr<<endl;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.