A professor of mathematics keeps the following information on each student to hi
ID: 3629170 • Letter: A
Question
A professor of mathematics keeps the following information on each student to his MATH 1420 CLASS: student last name, student first name, social security number, grades for five quzzies, grade for the final exam and the final grade average grade. Write a program that prompts the user to input data about as many as 25 students and compute the relevant grade.Students should be stored in a struct variable of type studentType. Use an array of 25 components of the type studentType to store the information.
Your program must contain at least the following function
a. A function that prompts the user for all the information for the student except the final grade.
b. A function that takes the information for one student and returns the final grade of the students which is computed as follow: the final grade is 75% of the quiz average plus 25% of the final exam.
c.A function to display a report that lists the students, and for each student display the quiz average, the final exam grade and the final-quiz average.
Your program must output each student's name in this form: last name followed by a comma, followed by a space, followed by the first name, and the name must be left justified.
Moreover, the function main should other declaring variables , be just a collection of the function calls.
Explanation / Answer
please rate - thanks
#include <iostream>
#include <iomanip>
using namespace std;
struct studentType
{ string first;
string last;
string SS;
int quiz[5];
int final;
double average;
};
void getInput(studentType[],int);
double compute(studentType);
double quizavg(studentType);
void print(studentType[],int);
int main ()
{studentType s[25];
int n,i;
cout<<"How many students in the class? ";
cin>>n;
getInput(s,n);
print(s,n);
system("pause");
return 0;
}
void getInput(studentType s[],int n)
{int i,j;
for(i=0;i<n;i++)
{cout<<"for student "<<i+1<<endl;
cout<<"Enter first name: ";
cin>>s[i].first;
cout<<"Enter last name: ";
cin>>s[i].last;
cout<<"Enter Social Security number: ";
cin>>s[i].SS;
for(j=0;j<5;j++)
{cout<<"Enter quiz "<<j+1<<" grade: ";
cin>>s[i].quiz[j];
}
cout<<"Enter final exam grade: ";
cin>>s[i].final;
s[i].average=compute(s[i]);
}
}
double compute(studentType s)
{
double avg;
avg=quizavg(s);
return avg*.75+s.final*.25;
}
double quizavg(studentType s)
{int i,sum;
for(i=0;i<5;i++)
sum+=s.quiz[i];
return sum/5.;
}
void print(studentType s[],int n)
{int i;
string name;
cout<<"name quiz average final exam grade final-quiz average ";
for(i=0;i<n;i++)
{name=s[i].last;
name=name+", ";
name=name+s[i].first;
cout<<setw(20)<<left<<name<<setw(12)<<right<<
quizavg(s[i])<<setw(18)<<s[i].final<<setw(20)<<s[i].average<<endl;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.