An academic department of Information School wants to generate students report for TEN final year students which will be graduated soon. A name list of TEN students and their FOUR scores are stored in arrays. Write a complete C++ program to do the following:
a. Create 5 parallel arrays to store the:
i. TEN students name called studentName
ii. TEN scores for subject CS402 called cs402
iii. TEN scores for subject CS315 called cs315
iv. TEN scores for subject CS607 called cs607
v. TEN scores for subject CS558 called cs558
b. Read input into the arrays and display them.
c. After processing all the information, the program should:
i. Calculate the average marks for each student
ii. Determine how many students are graduated with first class degree, with average score more than 80%.
iii. Display best student with highest score of each subject iv. Display best student with the highest average score to be awarded with chancellor award
#include <iostream>
#include <string>
using namespace std;
int main() {
//a. Create 5 parallel arrays to store the:
//i. TEN students name called studentName
string studentName[10];
//ii. TEN scores for subject CS402 called cs402
int cs402[10];
//iii. TEN scores for subject CS315 called cs315
int cs315[10];
//iv. TEN scores for subject CS607 called cs607
int cs607[10];
//v. TEN scores for subject CS558 called cs558
int cs558[10];
//b. Read input into the arrays and display them.
for(int i=0;i<10;i++){
cout<<"Enter the information for the student "<<(i+1)<<"\n";
cout<<"Enter the student name: ";
getline(cin,studentName[i]);
cout<<"Enter the student score for subject CS402: ";
cin>>cs402[i];
cout<<"Enter the student score for subject CS315: ";
cin>>cs315[i];
cout<<"Enter the student score for subject CS607: ";
cin>>cs607[i];
cout<<"Enter the student score for subject CS558: ";
cin>>cs558[i];
cout<<"\n";
cin.ignore();
}
//c. After processing all the information, the program should:
//i. Calculate the average marks for each student
int bestStudentScoreCS402=0;
int bestStudentScoreCS315=0;
int bestStudentScoreCS607=0;
int bestStudentScoreCS558=0;
string bestStudentNameCS402="";
string bestStudentNameCS315="";
string bestStudentNameCS607="";
string bestStudentNameCS558="";
int studentsGraduatedFirstClassDegree=0;
int bestStudentScoreHighestAverage=0;
string bestStudentNameHighestAverage="";
for(int i=0;i<10;i++){
float averageMarks=(float)(cs402[i]+cs315[i]+cs607[i]+cs558[i])/4.0;
cout<<"The average mark for student "<<(i+1)<<" is: "<<averageMarks<<"\n";
//ii. Determine how many students are graduated with first class degree, with average score more than 80%.
if(averageMarks>80){
studentsGraduatedFirstClassDegree++;
}
if(cs402[i]>bestStudentScoreCS402){
bestStudentScoreCS402=cs402[i];
bestStudentNameCS402=studentName[i];
}
if(cs315[i]>bestStudentScoreCS315){
bestStudentScoreCS315=cs315[i];
bestStudentNameCS315=studentName[i];
}
if(cs607[i]>bestStudentScoreCS607){
bestStudentScoreCS607=cs607[i];
bestStudentNameCS607=studentName[i];
}
if(cs558[i]>bestStudentScoreCS558){
bestStudentScoreCS558=cs558[i];
bestStudentNameCS558=studentName[i];
}
if(averageMarks>bestStudentScoreHighestAverage){
bestStudentScoreHighestAverage=averageMarks;
bestStudentNameHighestAverage=studentName[i];
}
}
cout<<studentsGraduatedFirstClassDegree<<" students are graduated with first class degree, with average score more than 80%.\n";
//iii. Display best student with highest score of each subject
cout<<"The best student for subject CS402 is: "<<bestStudentNameCS402<<"\n";
cout<<"The best student for subject CS315 is: "<<bestStudentNameCS315<<"\n";
cout<<"The best student for subject CS607 is: "<<bestStudentNameCS607<<"\n";
cout<<"The best student for subject CS558 is: "<<bestStudentNameCS558<<"\n";
//iv. Display best student with the highest average score to be awarded with chancellor award
cout<<"The best student with the highest average score is: "<<bestStudentNameHighestAverage<<"\n";
system("pause");
return 0;
}
Comments
Leave a comment