Create a modular program that will accept the inputs for assignment grade (4 inp
ID: 3683416 • Letter: C
Question
Create a modular program that will accept the inputs for assignment grade (4 inputs), lab test grades(3 inputs), lecture test grades(4 inputs), postlab grades(9 inputs) inputs, quiz grades(9 inputs) and clicker grad from the user. The program then provides the following menu to the user. Write different functions to implement the functionality of this program to compute the expected values.
1. Show the Grades in a Tabular Format
2. Show the Overall Grade (number and letter)
3. Exit if any other input
Enter your choice:_
The grades are calculated based on the following breakdown:
Assignments 1-4 Each 5% Total 20%
Lab Tests 1-3 Each 10% Total 30%
Lecture Tests 1-4 Each 10% Total 40%
Post Labs 1-9 Each .3% Total 2.7%
Quizzes 1-9 Each .4% Total 3.6%
Clickers Total 3.7%
The letter grade is calculated as below:
90-100= A
80-89 = B
70-79 = C
60-69 = D
0-59 = F
Your program should ask the user for the scores based on the above data. Then, the final score will be calculated and printed in Here is an example run: Enter the score for the first assignment: 89.5 Enter the score for the second assignment: 85 Enter the score for the third assignment: 86.90 .......... The Overall Grade is 86.5. Letter Grade: B
Explanation / Answer
/*** C++ code to Create a modular program ***/
#include <iostream> // std::cout
#include <stdlib.h>
using namespace std;
void tabular (float assignments[], int n1, float labtest[], int n2, float lecturetest[], int n3, float postlab[], int n4, float quizzes[], int n5, float clicker)
{
cout << " Student Scorecard ";
cout << "------------------------------ ";
cout << "Test Numeric Grade ";
cout << "------------------------------ ";
for (int i = 0; i < n1; ++i)
{
cout << "assignment " << i+1 << " " << assignments[i]<< endl;
}
cout << "------------------------------ ";
for (int i = 0; i < n2; ++i)
{
cout << "lab test " << i+1 << " " << labtest[i]<< endl;
}
cout << "------------------------------ ";
for (int i = 0; i < n3; ++i)
{
cout << "lecture test " << i+1 << " " << lecturetest[i]<< endl;
}
cout << "------------------------------ ";
for (int i = 0; i < n4; ++i)
{
cout << "post lab " << i+1 << " " << postlab[i]<< endl;
}
cout << "------------------------------ ";
for (int i = 0; i < n5; ++i)
{
cout << "quiz " << i+1 << " " << quizzes[i]<< endl;
}
cout << "------------------------------ ";
cout << "Clickers " << " " << clicker<< endl;
cout << "------------------------------ ";
}
void Overall_grade (float assignments[], int n1, float labtest[], int n2, float lecturetest[], int n3, float postlab[], int n4, float quizzes[], int n5, float clicker)
{
float sum1 = 0;
for (int i = 0; i < n1; ++i)
{
sum1 = sum1 + assignments[i];
}
sum1 = sum1/(n1*100);
sum1 = sum1*0.2;
float sum2 = 0;
for (int i = 0; i < n2; ++i)
{
sum2 = sum2 + labtest[i];
}
sum2 = sum2/(n2*100);
sum2 = sum2*0.3;
float sum3 = 0;
for (int i = 0; i < n3; ++i)
{
sum3 = sum3 + lecturetest[i];
}
sum3 = sum3/(n3*100);
sum3 = sum3*0.4;
float sum4 = 0;
for (int i = 0; i < n4; ++i)
{
sum4 = sum4 + postlab[i];
}
sum4 = sum4/(n4*100);
sum4 = sum4*0.027;
float sum5 = 0;
for (int i = 0; i < n5; ++i)
{
sum5 = sum5 + quizzes[i];
}
sum5 = sum5/(n5*100);
sum5 = sum5*0.036;
float sum = sum1 + sum2 + sum3 + sum4 + sum5 + (clicker/100)*0.037;
sum = sum * 100;
cout << "The Overall Grade is: "<< sum<< endl;
char letter;
if(sum >= 90) letter = 'A';
else if(sum >= 80) letter = 'B';
else if(sum >= 70) letter = 'C';
else if(sum >= 60) letter = 'D';
else if(sum < 60) letter = 'F';
cout << "Letter Grade: " << letter << endl;
}
int main ()
{
float assignments[4];
float labtest[3];
float lecturetest[4];
float postlab[9];
float quizzes[9];
float clicker;
for (int i = 0; i < 4; ++i)
{
cout << "Enter the score for the assignment " << i+1 <<": ";
cin >> assignments[i];
}
for (int i = 0; i < 3; ++i)
{
cout << "Enter the score for the lab test " << i+1 <<": ";
cin >> labtest[i];
}
for (int i = 0; i < 4; ++i)
{
cout << "Enter the score for the lecture test " << i+1 <<": ";
cin >> lecturetest[i];
}
for (int i = 0; i < 9; ++i)
{
cout << "Enter the score for the Post Labs " << i+1 <<": ";
cin >> postlab[i];
}
for (int i = 0; i < 9; ++i)
{
cout << "Enter the score for the Quiz " << i+1 <<": ";
cin >> quizzes[i];
}
cout << "Enter the score for the Clickers: ";
cin >> clicker;
while(true)
{
int input;
cout << "1. Show the Grades in a Tabular Format 2. Show the Overall Grade (number and letter)3. Exit if any other input ";
cout << "Enter your choice: ";
cin >> input;
if(input == 1) tabular(assignments,4,labtest,3,lecturetest,4,postlab,9,quizzes,9,clicker);
else if(input == 2) Overall_grade(assignments,4,labtest,3,lecturetest,4,postlab,9,quizzes,9,clicker);
else return 0;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.