70 888
Assignments Done
98,9%
Successfully Done
In March 2019

# Answer to Question #50452 in C++ for Goerge

Question #50452
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)0))))))))))))))))))))))))))))))))

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
#include <cstdlib>
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int n;
printf("Input number of students: ");
cin>>n;
/*Create array to store data of each student.*/
int ID[n];
float first[n];
float second[n];
float final[n];
float total[n];
float sum = 0;
/*Read data for each student.*/
for (int i = 0; i < n; i++) {
printf("Enter data for students %d: \n", i + 1);
printf(" - ID: ");
cin >> ID[i];
printf(" - First mark: ");
cin >> first[i];
printf(" - Second mark: ");
cin >> second[i];
printf(" - Final mark: ");
cin >> final[i];
/* Compute total mark.*/
total[i] = first[i] + second[i] + final[i];
/* Calculate the sum.*/
sum += total[i];
/* Calculate the grate using total mark.*/
if (total[i] >= 90)
else if (total[i] >= 80)
else if (total[i] >= 70)
else if (total[i] >= 60)
else grade[i] = 'F';
printf("\n");
}
printf("\n");
/* Calculate average mark. */
float classAveMark = sum / n;
printf("%6s %9s %6s %6s %6s %6s %4s\n", "St_Nm", "ID", "Fisrt", "Second", "Final", "Total", "Grade");
for (int i = 0; i < n; i++)
printf("%6d %9d %6.1f %6.1f %6.1f %6.1f %5c\n", i + 1, ID[i], first[i], second[i], final[i], total[i], grade[i]);
/* Print class mark.*/
printf("\nClass average for %d students is: %.2f\n", n, classAveMark);
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!