Write a program to do the following. When the program starts, itgenerates random
ID: 3618174 • Letter: W
Question
Write a program to do the following. When the program starts, itgenerates random grades for HW1, HW2, Quiz1, Quiz2, Midterm, andFinal for each of the 15 students in a class. Note that the gradesshould be a double value and generated between 50]100 (seerandom_example.cc for reference). Then, the program should printout the following table after calculating the correspondingstatistics.Average: the average grade of each subitem;
Total: total grade of each student. Homeworks are 5% each, Quizesare 10% each, Midterm is 30% and Final is 40%.
Overall grade: >=90 for A, >=80 for B, >=70 for C, >=60for D, the F for the rest.
HW1 HW2 Quiz1 Quiz2 Midterm Final TotalGrade
1 79 93 91 73 74 99 86.8 B
2 72 80 92 82 63 72 72.7 C
3 81 73 92 62 97 99 91.8 A
4 70 85 94 94 67 97 85.45 B
5 78 61 65 93 91 63 75.25 C
6 66 66 98 65 98 83 85.5 B
7 62 99 72 90 67 91 80.75 B
8 73 79 100 79 65 74 74.6 C
9 73 85 93 69 85 71 78 C
10 63 67 82 74 74 96 82.7 B
11 65 75 72 90 88 74 79.2 C
12 80 76 82 82 85 80 81.7 B
13 66 75 88 63 76 65 70.95 C
14 63 86 72 86 92 75 80.85 B
15 71 77 86 94 97 64 80.1 B
Average 70.80 78.47 85.27 79.7381.27 80.20 80.42
Hint:
. useh h in printf for alignment.
. use detailed formatting such as g%6.2fh to print out doublevalues with limited space.
Two dimensional array is suggested for the implementation.
. double grade[15][6];
. double total[15];
. double average[7];
Bonus:
In addition to calculate the average, calculate the gMeanh(that is,the number of students with smaller grades is
the same as the number of students with greater grades) too.
*/
Hello,
The above is just information is basically what I need to do towrite the c-program code. I just want to know if I am taking theright approach or need to do something else. I haven't put the partabout calculating the total and grade yet as well as the averagebecause I'm not sure where to start it. Thanks.
#include <stdio.h>
#include <stdlib.h>
int main()
{
doublehw1,hw2,quiz1,quiz2,midterm,final,total,grade;
int i;
int j;
printf("* HW1 HW2 Quiz1 Quiz2 Midterm Final Total Grade ");
for(i=0; i<16; i++) {
hw1 = 50.0+rand() %100;
hw2 = 50.0+rand() %100;
quiz1 = 50.0+rand() %100;
quiz2 = 50.0+rand() %100;
midterm = 50.0+rand() %100;
final = 50.0+rand() %100;
total = 0;
grade = 0;
printf("%d %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f ",i,hw1,hw2,quiz1,quiz2,midterm,final,total,grade);
}
printf(" Average:");
printf(" ");
system("pause");
}
Explanation / Answer
please rate - thanks you are doing it incorrectly. this should put you on theright track #include #include int main() { double grade[15][6],total[15], average[7]; int i; int j; char letter[15]; printf("* HW1 HW2 Quiz1 Quiz2 Midterm Final Total Grade "); for(i=0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.