C++ Structure Program You are to write a program that will read in up tp 15 stud
ID: 3538615 • Letter: C
Question
C++ Structure Program
You are to write a program that will read in up tp 15 students with student information and grades.
Your program will compute an average and print out certain reports.
Format: The information for each student in on seperate lines of input. The first data will be the student's ID number,
next line is the student's name, nxt the student's classification, and the last line
are the 10 grades where the last grade is to be counted twice(as the final).
Read in the students, computere their averages and print out the following:
Print out each student ID and their average.
Print out all the Seniors in a list with their name and average.
Sort on average and print out name and average.
Be sure to label each list and line up all ouput in straight columns,.
This is what the input file looks like:
12345
Junior
Two B Orknot
85 68 85 84 95 100 86 87 85
81032
Senior
Mack Camp
77 73 77 79 80 73 76 73 78
71433
Senior
Cant Never Koud
88 89 83 80 93 95 97 99 100
55231
Junior
Two N Finitee
95 95 100 85 85 70 85 90 85
18382
Junior
Eve N Ghigher
100 100 100 100 100 100 100 100 100
74223
Senior
Tow Jammer
93 88 77 66 77 86 89 95 92
45322
Senior
Uh Nuther
95 90 85 80 70 80 85 90 85
82843
Senior
Lue Knew Lotts
98 99 97 100 100 99 96 96 97
39932
Junior
Ah C Moto
65 67 70 77 73 69 70 66 67
81399
Junior
Too Much
83 84 88 77 88 88 73 75 80
99392
Senior
Just Abot Done
75 80 77 77 77 80 82 79 80
13929
Senior
Al Dah Zame
90 90 90 90 90 90 90 90 90
72221
Junior
Tu Phinish Awf
100 95 90 85 80 75 70 65 60
Explanation / Answer
I did it, but could not post it now time, because of downtime of this website
Hope you will like it
#include <iostream>
#include <string.h>
#include <fstream>
http://www.chegg.com/homework-help/questions-and-answers/c-structure-programyou-write-program-read-tp-15-students-student-information-grades-progra-q4146619
using namespace std;
struct Student {
int id;
string classification;
string name;
double avg;
};
int main()
{
ifstream in("Grade.txt");
struct Student Students[15];
int i=0,j=0;
while((i<15 )&&(!in.eof()))
{
in>>Students[i].id;
in>>Students[i].classification;
getline(in,Students[i].name);
getline(in,Students[i].name);
double avg=0;
int j=0;
int marks;
for(j=0;j<9;j++)
{
in>>marks;
avg=avg+marks;
}
avg=avg+marks;
avg=avg/10.0;
Students[i].avg=avg;
i++;
}
int noofstudents=i;
cout<<"Id Average"<<endl;
for(i=0;i<noofstudents;i++)
{
cout<<Students[i].id<<" "<<Students[i].avg<<endl;
}
cout<<"Senior's Name Average"<<endl;
for(i=0;i<noofstudents;i++)
{
if(Students[i].classification.compare("Senior")==0)
{
cout<<Students[i].name<<" "<<Students[i].avg<<endl;
}
}
for(i=0;i<noofstudents;i++)
{
for(j=0;j<noofstudents;j++)
{
if(Students[i].avg>Students[j].avg)
{
struct Student temp=Students[i];
Students[i]=Students[j];
Students[j]=temp;
}
}
}
cout<<"Name Average"<<endl;
for(i=0;i<noofstudents;i++)
{
cout<<Students[i].name<<" "<<Students[i].avg<<endl;
}
cin>>i;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.