Answer to Question #50405 in C++ for Elie

Question #50405
Write a program that can enter marks for number of students and calculate their Total and class
average with the following format
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.
Use the following functions to find
1. void inputID(int[]);
2. void inputMarks(double[]);
3. double ClassAverage(double []);
4. void Grade(double[],char []);
5. void Total(double[],double [],double [],double[]);
6. void print(int[] , double[], double[] , double[],double[], char[]);

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-14T02:31:12-0500

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

usingnamespace std;

constint SIZE = 10;

//Declaringof prototypes functions
voidinputID(int[]);
voidinputMarks(double[]);
doubleClassAverage(double []);
voidGrade(double[],char[]);
voidTotal(double[],double[],double [],double[]);
voidprint(int[] , double[],double[] , double[],double[], char[]);

//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";

//Callingfunctions
inputID(ID);

cout<<endl<<"First: "<<endl;
inputMarks(marksFirst);

cout<<endl<<"Second: "<<endl;
inputMarks(marksSecond);

cout<<endl<<"Final: "<<endl;
inputMarks(marksFinal);

//Callingfunction determination Total
Total(marksFirst, marksSecond,marksFinal, total);

//Callingfunction determination Grade
Grade(total,courseGrade);

//Callingfunction print
print(ID, marksFirst, marksSecond,marksFinal, total, courseGrade);

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

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

voidinputMarks(double marks[])
{
for(int i=0; i<SIZE; i++)
{
cout<<"Enter marks for "<<i+1<< " student: "<<endl;
cin>>marks[i];
cout<<endl;

}
}

voidTotal(double marksFirst[],double marksSecond[],doublemarksFinal[],double total[])
{
for(int i=0; i<SIZE; i++)
{
total[i] = marksFirst[i] +marksSecond[i] + marksFinal[i];
}
}

voidGrade(double average[] ,char courseGrade[])
{

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';
}
}

}

voidprint(int ID[] , doublemarksFirst[], double marksSecond[] , double marksFinal[], doubletotal[], char courseGrade[])
{
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;
}

cout<<endl<<endl<<"Class average for 10 students is: "<<ClassAverage(total);

}

doubleClassAverage(double total[])
{
doubleavg=0;

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

returnavg/SIZE;
}


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