Answer to Question #50443 in C++ for Lia

Question #50443
1. Write a program that can enter marks for number of students and calculate their Total and class
average with the following format (((((WITHOUT using functions)))))

The inputs:

ID (As 1 dimension array of Integers), First (As1 dimension array of Doubles), Second (As 1 dimension
array of Doubles), Final (As 1 dimension array of Doubles), Total (As 1 dimension array of Doubles), Grad
(As 1 dimension array of Chars)
The Grades are: A for 90’s, B for 80’s, C for 70’s, D for 60’s and F for less than 60.


Example of the output:
St_Nm ID First Second Final Total Grade
1 20071156 15.5 16.5 30.1 62.1 D
2 20071154 15.0 16.5 30.1 62.6 D

Class average for 10 students is: 72.5
1
Expert's answer
2015-01-21T02:53:23-0500

//Connectinglibraries
#include<iostream>
#include<iomanip>

usingnamespace std;

constint SIZE = 10;


//Create a main function
intmain()
{
//Declaringvariables
intID[SIZE]={0};
doublemarksFirst[SIZE]={0}, marksSecond[SIZE]={0}, marksFinal[SIZE]={0};
doubletotal[SIZE]={0};
doubleaverage[SIZE]={0};
charcourseGrade[SIZE]="\0";

//Input ID
for(int i=0; i<SIZE; i++)
{
cout<<"Enter ID for "<<i+1<< " student: ";
cin>>ID[i];
cout<<endl;

//Inputmarks for first
cout<<endl<<"First: "<<endl;
cout<<"Enter marks for "<<i+1<< " student: "<<endl;
cin>>marksFirst[i];
cout<<endl;

//Inputmarks for second
cout<<endl<<"Second: "<<endl;
cout<<"Enter marks for "<<i+1<< " student: "<<endl;
cin>>marksSecond[i];
cout<<endl;

//Inputmarks for final
cout<<endl<<"Final: "<<endl;
cout<<"Enter marks for "<<i+1<< " student: "<<endl;
cin>>marksFinal[i];
cout<<endl;

}

//DeterminationTotal
for(int i=0; i<SIZE; i++)
{
total[i] = marksFirst[i] +marksSecond[i] + marksFinal[i];
}



//DeterminationGrade
for(int i=0; i<SIZE; i++)
{
if(average[i] >= 90)
{
courseGrade[i] = 'A';
}
elseif (average[i] >= 80 && average[i]< 90)
{
courseGrade[i] = 'B';
}
elseif (average[i] >= 70 && average[i]< 80)
{
courseGrade[i] = 'C';
}
elseif (average[i] >= 60 && average[i]< 70)
{
courseGrade[i] = 'D';
}
elseif (average[i] < 60)
{
courseGrade[i] = 'F';
}
}



//Print
cout<<"St_Nm ID First Second Final Total Grade"<<endl;

for(int i=0; i<SIZE; i++)
{
cout<<setw(4)<<i+1<<setw(9)<<ID[i]<<setw(5)<<marksFirst[i]<<setw(7)<<marksSecond[i]<<setw(7)<<marksFinal[i]<<setw(7)<<total[i]<<setw(3)<<courseGrade[i];
cout<<endl;
}

doubleavg=0;
for(int i=0; i<SIZE; i++)
{
avg+=total[i];
}


cout<<endl<<endl<<"Class average for 10 students is: "<<avg/SIZE;

//Stop console
cin.get();
cin.get();
return 0;
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS