77 961
Assignments Done
98,4%
Successfully Done
In August 2019

# Answer to Question #50326 in C++ for John

Question #50326
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),marks(as 2 dimensional array of double), 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. void Total(double[]);
4. void Grade(double[],char[]);
5. double ClassAverage(double[]);
6. void print(int[],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
Expert's answer
//Question #50326, Programming, C++
#include <iostream>
#include <conio.h>
using namespace std;
int n; // general number of students
//function prototypes
void inputID(int[]);
void inputMarks(double []);
void Total(double[]);
void Grade(double[],char[]);
double ClassAverage(double[]);
void print(int[],double[],char[]);
void inputID(int idArray[]) {
cout << "Enter id's of students :\n";
for (int i = 0; i < n; i++) {
cin >> idArray[i];
}
}
void inputMarks(double marks[]) {
for (int i = 0; i < n; i++) {
cout << "Enter first, second and final marks for " << i + 1 << " student:\n";
cin >> marks[i] >> marks[i] >> marks[i];
}
}
void Total(double marks[]) {
for (int i = 0; i < n; i++) {
marks[i] = marks[i] + marks[i] + marks[i];
}
}
void Grade(double marks[],char grad[]) {
for (int i = 0; i < n; i++) {
if (marks[i] < 60) {
grad[i] = 'F';
continue;
}
if (marks[i] >= 60 && marks[i] < 70) {
grad[i] = 'D';
continue;
}
if (marks[i] >= 70 && marks[i] < 80) {
grad[i] = 'C';
continue;
}
if (marks[i] >= 80 && marks[i] < 90) {
grad[i] = 'B';
continue;
}
if (marks[i] >= 90) {
grad[i] = 'A';
continue;
}
}
}
double ClassAverage(double marks[]) {
double average = 0;
for (int i = 0; i < n; i++) {
average += marks[i];
}
return (average / n);
}
void print(int idArray[], double marks[], char grade[]) {
cout << "St_Nm\tID\tFirst\tSecond\tFinal\tTotal\tGrade" << endl;
for (int i = 0; i < n; i++) {
cout << i + 1 << "\t" << idArray[i] << "\t" << marks[i] << "\t" << marks[i] << "\t" << marks[i] << "\t" << marks[i] << "\t" << grade[i] << endl;
}
cout << endl;
cout << endl;
cout << "Class average for " << n <<" students is: " << ClassAverage(marks) << endl;;
}
void main() {

cout << "Enter general number of students:\n";
cin >> n;
cout << endl;
int *idArray = new int[n];
inputID(idArray);
double marks;
inputMarks(marks);
Total(marks);
char grade;
Grade(marks,grade);
print(idArray, marks, grade);
_getch();
}
``﻿``

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 first!

Submit