Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

* Calculates the student * averages and quiz averages based upon input from the

ID: 3553717 • Letter: #

Question

* Calculates the student * averages and quiz averages based upon input from the user. Modify this program to read in the following grade text file, * with a maximum number of students set to 35 and having five quiz scores for each student. The output should be displayed to both the console and the output file. Please submit the output file created by the program with the C++ source code and executable ...Copy paste the program into the answer area make sure you post small discrepitions of what is happening

Pts Pos.

Earned

Item # & Description


Includes a comment line with students name and homework number, date

10

Includes comments with helpful explanations or identification of various program characteristics.

10

Includes a header printout with course, homework #, and student name

20

Includes reading of input file, output of student and quiz averages to screen

20

Includes an output file with output of student and quiz averages to file which is attached

20

Has proper looping, branching and logic flow

10

Well formatted output, Error message are generated with Checks for errors on file opens

Pts Pos.

Earned

Item # & Description


Includes a comment line with students name and homework number, date

10

Includes comments with helpful explanations or identification of various program characteristics.

10

Includes a header printout with course, homework #, and student name

20

Includes reading of input file, output of student and quiz averages to screen

20

Includes an output file with output of student and quiz averages to file which is attached

20

Has proper looping, branching and logic flow

10

Well formatted output, Error message are generated with Checks for errors on file opens


Explanation / Answer

// NAME: XYZ HOMEWORK NO: 2 DATE:03/04/2014

#include <iostream>

#include <fstream>

using namespace std;


int main()

{


ifstream myfile;

int n,n1;

cout<<"NAME: XYZ HOMEWORK NO: 2 DATE:03/04/2014"<<endl;

cout<<"enter no of students"<<endl;

cin>>n1;

float temp;

float quiz[n1];

cout<<"Enter marks of all student in all 5 quizes "<<endl;

for(int i=0;i<n1;i++)

{

quiz[i]=0;


for(int j=0;j<5;j++)

{

cout<<"Enter marks of student no "<<i+1<<" in quiz no "<<j+1<<": ";

cin>>temp;

cout<<" "<<endl;

quiz[i]+=temp;

}

quiz[i]=quiz[i]/5;

}

cout<<"The average marks of all student in all 5 quizes are "<<endl;

for(int j=0;j<n1;j++)

{

cout<<"Average of marks of student no "<<j+1<<" in all quizes is "<<quiz[j]<<endl;

}


cout<<" The average values of all students (values taken from an external file) are"<<endl;

myfile.open ("input.txt");//taking input from a file

myfile>>n; //no of students

float data;

float sum;

ofstream ifile;//output file

ifile.open ("output.txt");

ifile<<" The average values of all students are"<<endl;


for (int i=0;i<n;i++)

{

sum=0;

for(int j=0;j<5;j++)

{

myfile>>data;

sum+=data;

}

sum=sum/5;//creating average of each student

cout<<"Student "<<i+1<<" is "<<sum<<endl;//writing average to an console

ifile<<"Student "<<i+1<<" is "<<sum<<endl;//writing average to an output file

}

myfile.close();

ifile.close();


return 0;

}