Write a C program. The program should output the average of quizzes, laboratory exercises and assignments and compute the equivalent percentage by getting the 40%. Input the major examination and get the equivalent by getting the 60% of it. The program should output the Prelim Grade: Prelim Grade = class participation + major examination
Remarks: if the grade is greater than or equal to 75 display PASSED, otherwise FAILED
SAMPLE RUN:
Class Participation
Quiz 1: 90
Quiz 2: 95
Quiz 3: 89
Quiz 4: 80
Average: 88.5
Lab. 1: 100
Lab. 2: 95
Lab. 3: 80
Lab 4: 70
Average: 86.25
Assignment 1: 100
Assignment 2: 80
Assignment 3: 89
Assignment 4: 75
Average: 86
Class Participation: 34.73
Prelim Exam: 95
%: 57.00
Prelim Grade: 91.73
Remarks: PASSED
#include <iostream>
#include <iomanip>
using namespace std;
double GetAverage(const char *name, int n) {
int total=0, mark;
double avg;
for (int i=0; i<n; i++) {
cout << name << i+1 << ": ";
cin >> mark;
total += mark;
}
avg = static_cast<double>(total) / n;
cout << "Average: " << avg << endl;;
return avg;
}
int main() {
double quiz_avg;
double lab_avg;
double assign_avg;
cout << "Class Participant" << endl;
quiz_avg = GetAverage("Quiz", 4);
lab_avg = GetAverage("Lab", 4);
assign_avg = GetAverage("Assignment", 4);
double class_part = 0.4 * (quiz_avg + lab_avg + assign_avg) / 3;
cout << "Class Participation: " << fixed << setprecision(2) << class_part << endl;
int exam_mark;
cout << "Prelim Exam: ";
cin >> exam_mark;
double exam = 0.6 * exam_mark;
cout << "% " << exam << endl;
double grade = class_part + exam;
cout << "Prelim Grade: " << grade << endl;
cout << "Remarks: ";
if (grade >= 75) {
cout << "PASSED" << endl;
}
else {
cout << "FAILED" << endl;
}
}
Comments
Leave a comment