Student ID numbers grades and year of schools of 10 students

Student ID numbers, grades, and year of schools of 10 students are given as below where the full marks for each examination is 100. Also, there are 10 homework of 10 points each and the column below describes the total score of a student in all the homework.

The following nested structure is to be used:

struct score{
float HW;
float Exam1;
float Exam2;
float Exam3;
};
struct student{
int id;
int YearOfSchool;
sturct score course_scores;
};

Q1.Declare a Global 10 length array of structure variables of type “student” and call it st_information[10]. So, each element of this array is a structure variable of type “student”. Initialize (set values to) the elements of the array using the student information for 10 students provided above. Write a function that will display the “overall score” of all 10 students in a single column.

Q.2 Write another function that will display two columns; in the first column there will be student ids and the second column will contain the “overall score” of the corresponding students.

Q.3 Write a program that computes course average for all three individual exams and the average of “overall scores”. The output of this function will be four possible floating point numbers, one for each of the three exams and one for the overall score.

Q4: Print average weighted grades for students based on different years of school (freshmen, sophomores, juniors, and seniors) on the console.

ID Number Year of SchoolHomework Exam 1 Exam 2 90 86 Exam3 78 80 78 72 94 67 82 67 85 76 95 84 76 72 85 86 80 75 82 76 83 79 84 2 3 96 76 78 72 2 3 75 52 98 76 79 74 eighting schema for each of the component towards \"overall score\" for the course is as follows: Homework-20% Exam I 25% Exam 2-25% Exam3 30% F or example, overall scorefor 1st student is 78*(20/100)+67*(25/100)+90* (25/100)+ 80 (30/100)

Solution

#include <iostream>
using namespace std;

struct score{
float HW;   
float Exam1;
float Exam2;
float Exam3;
};


struct student{
int id;
int YearofSchool;
struct score course_scores;
};
struct student st_information[10];

void displayOverallScore()
{
int overallScore[10],i;
cout<<\"\ OVERALL SCORE OF STUDENTS\";
for(i=0;i<10;i++)
{
overallScore[i] = st_information[i].course_scores.HW * 0.2 + st_information[i].course_scores.Exam1 *0.25 + st_information[i].course_scores.Exam2*0.25 +st_information[i].course_scores.Exam3 *0.3;
cout<<\"\ Overall Score for Student \"<<i+1<<\" : \"<<overallScore[i];
}

}

void displayOverallScoreID()
{
int overallScore[10],i;
cout<<\"\ STUDENT ID AND OVERALL SCORE\";
for(i=0;i<10;i++)
{
cout <<\"\ Student Id :\"<<st_information[i].id;
overallScore[i] = st_information[i].course_scores.HW * 0.2 + st_information[i].course_scores.Exam1 *0.25 + st_information[i].course_scores.Exam2*0.25 +st_information[i].course_scores.Exam3 *0.3;
cout<<\"\ Overall Score : \"<<overallScore[i];
}

}

void AverageExamsOverallScore()
{
int overallScore[10],AverageExams[10],i;
int sum=0;
cout<<\"\ Average of Overall Score\";
for(i=0;i<10;i++)
{
overallScore[i] = st_information[i].course_scores.HW * 0.2 + st_information[i].course_scores.Exam1 *0.25 + st_information[i].course_scores.Exam2*0.25 +st_information[i].course_scores.Exam3 *0.3;
cout<<\"\ Overall Score for student : \"<<overallScore[i];
sum = sum +overallScore[i];
}

cout<< \"\ Average overall score for all students:\"<<sum/10;

for(i=0;i<10;i++)
{
AverageExams[i] = (st_information[i].course_scores.Exam1 + st_information[i].course_scores.Exam2 +st_information[i].course_scores.Exam3)/3;
cout<<\"\ Average Exam1,Exam2 and Exam3 Score for student \"<<i+1<<\":\"<<AverageExams[i];

}

}

void AverageWeightedGrades()
{
int AverageFreshman,AverageSophomores,AverageJuniors,AverageSeniors;
AverageFreshman = AverageSophomores = AverageJuniors = AverageSeniors = 0;
int i;
int overallScore[10];
int count1=0;
int count2=0;
int count3=0;
int count4=0;

for(i=0;i<10;i++)
{
overallScore[i] = st_information[i].course_scores.HW * 0.2 + st_information[i].course_scores.Exam1 *0.25 + st_information[i].course_scores.Exam2*0.25 +st_information[i].course_scores.Exam3 *0.3;
cout<<overallScore[i];
}
for(i=0;i<10;i++)
{
if(st_information[i].YearofSchool == 1)
{
AverageFreshman =AverageFreshman + overallScore[i];
count1++;
}
else if(st_information[i].YearofSchool == 2)
{
AverageSophomores =AverageSophomores + overallScore[i];
count2++;
}
else if(st_information[i].YearofSchool == 3)
{
AverageJuniors =AverageJuniors + overallScore[i];
count3++;
}
  
else if(st_information[i].YearofSchool == 4)
{
  
AverageSeniors =AverageSeniors + overallScore[i];
count4++;

}
}   

cout<<\"\ Average Overall score of Freshman\"<<AverageFreshman/count1;
cout<<\"\ Average Overall score of Sophomores\"<<AverageSophomores/count2;
cout<<\"\ Average Overall score of Juniors\"<<AverageJuniors/count3;
cout<<\"\ Average Overall score of Seniors\"<<AverageSeniors/count4;
  
}

int main()
{
int i;
int id[10] = {1,2,3,4,5,6,7,8,9,10};
int year[10] = {4,3,2,3,4,1,2,3,4,2};
int hw[10] = {78,80,78,72,94,67,82,75,52,76};
int exam1[10] = {67,85,76,95,84,76,72,85,86,79};
int exam2[10] = {90,86,88,77,96,76,78,72,81,91};
int exam3[10] = {80,75,82,76,83,79,84,77,98,74};


for(i=0;i<10;i++)
{
st_information[i].id = id[i];
st_information[i].YearofSchool = year[i];
st_information[i].course_scores.HW = hw[i];
st_information[i].course_scores.Exam1 = exam1[i];
st_information[i].course_scores.Exam2 = exam2[i];
st_information[i].course_scores.Exam3 = exam3[i];
  
}

displayOverallScore();

displayOverallScoreID();

AverageExamsOverallScore();

AverageWeightedGrades();
return 0;
}

output:

Student ID numbers, grades, and year of schools of 10 students are given as below where the full marks for each examination is 100. Also, there are 10 homework
Student ID numbers, grades, and year of schools of 10 students are given as below where the full marks for each examination is 100. Also, there are 10 homework
Student ID numbers, grades, and year of schools of 10 students are given as below where the full marks for each examination is 100. Also, there are 10 homework
Student ID numbers, grades, and year of schools of 10 students are given as below where the full marks for each examination is 100. Also, there are 10 homework

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site