C++ QUESTION /*This program calculates a students course average using randomly
ID: 3884552 • Letter: C
Question
C++ QUESTION
/*This program calculates a students course average using randomly generated grades.
You will need to edit the program where 'FIXME' is noted as well as make some additions to complete the program.
The course weights are based on the actual values from the course syllabus.
*/
#include <iostream>
using namespace std;
int main() {
const double PARTICIPATION_MAX = 100.0;
const double ASSIGNMENTS_MAX =100.0;
const double HOMEWORK_CHALLENGES_MAX =100.0;
const double LABS_QUIZ_MAX = 100.0;
const double EXAM1_MAX = 100.0;
const double EXAM2_MAX = 100.0;
const double EXAM3_MAX = 100.0;
const double FINAL_EXAM_MAX = 100.0;
const double PROJECT_MAX = 100.0;
const double PARTICIPATION = .10;
const double ASSIGNMENTS = .10; //FIXME
const double HOMEWORK_CHALLENGES = .10; //FIXME
const double LABS_QUIZ = .15; //FIXME
const double EXAM1 = .10; //FIXME
const double EXAM2 = .10; //FIXME
const double EXAM3 = .10; //FIXME
const double FINAL_EXAM = 0; //FIXME
const double PROJECT = 0; //FIXME
// Have the user input their first and last name as a single input
/* Use a random number generator to calculate a score for each of the categories in the syllabus.
Each category can have a score in the range of 0 - 100, except exams 1-3 which can only be from 50 - 100.
Use a seed of 7 for your random number generator.
*/
/* Calculate the overall course grade & convert it to the appropriate letter grade */
coursePercentage = ((homeworkScore / HOMEWORK_MAX) * HOMEWORK_WEIGHT) // FIXME for all of the syllabus components
+ 0.0 // FIXME for midterm
+ 0.0; // FIXME for final
coursePercentage = coursePercentage * 100; // Convert fraction to %
cout << endl << "Your course percentage (FIXME): ";
cout << coursePercentage << endl;
// Output the users name, their grade for each individual category, and overall grade(number and letter) in the course.
return 0;
}
The grading scale for this course is
3 tests 30%
Final test 15%
In Class Participation 10%
Homework & Challenges* 10%
Labs & Quizzes 15%
Project 20%
A 90-100
B 80-89
C 70-79
D 60-69
F <-60
please use this scale to answer. Donot use A- or a+ or b+
just A,B,C,D,F as mentioned up
90-100 is A donot mention a+ or a- just write a code from 90-100 is A
Explanation / Answer
#include<cstdlib>
#include<cstdio>
#include <ctime>
#include <iostream>
using namespace std;
//Function returns the letter grade for each mark percentage
char getGrade(double per)
{
per = per * 100;
//Checks the percentage and returns the grade
if(per >= 9)
return 'A';
else if(per >= 8)
return 'B';
else if(per >= 7)
return 'C';
else if(per >= 6)
return 'D';
else
return 'F';
}//End of function
//Main function definition
int main()
{
//Constants for maximum mark
const double PARTICIPATION_MAX = 100.0;
const double ASSIGNMENTS_MAX =100.0;
const double HOMEWORK_CHALLENGES_MAX =100.0;
const double LABS_QUIZ_MAX = 100.0;
const double EX1_MAX = 100.0;
const double EX2_MAX = 100.0;
const double EX3_MAX = 100.0;
const double FINAL_EX_MAX = 100.0;
const double PROJECT_MAX = 100.0;
//Constants for percentage
const double PARTICIPATION = .10;
const double ASSIGNMENTS = .10; //FIXME
const double HOMEWORK_CHALLENGES = .10; //FIXME
const double LABS_QUIZ = .15; //FIXME
const double EX1 = .10; //FIXME
const double EX2 = .10; //FIXME
const double EX3 = .10; //FIXME
const double FINAL_EX = 0; //FIXME
const double PROJECT = 0; //FIXME
//Array to store first name and last name
char firstName[20], lastName[20];
//Variables for storing marks generated randomly
double participation, assignmens, homework, labQuiz, ex1, ex2, ex3, finalEx, project;
//variables to store percentage marks
double participationPer, assignmensPer, homeworkPer, labQuizPer, ex1Per, ex2Per, ex3Per, finalExPer, projectPer;
//Variables to store letter grade
char participationGrade, assignmensGrade, homeworkGrade, labQuizGrade, ex1Grade, ex2Grade, ex3Grade, finalExGrade, projectGrade;
//Have the user input their first and last name as a single input
cout<<" Enter the first and last name of the student: ";
//Accepts name
cin>>firstName;
fflush(stdin);
cin>>lastName;
/* Use a random number generator to calculate a score for each of the categories in the syllabus.
Each category can have a score in the range of 0 - 100, except exams 1-3 which can only be from 50 - 100.
Use a seed of 7 for your random number generator.
*/
srand(time(NULL));
//Randomly generate marks
participation = rand() % (int)PARTICIPATION_MAX;
assignmens = rand()% (int)ASSIGNMENTS_MAX;
homework = rand()% (int)HOMEWORK_CHALLENGES_MAX;
labQuiz = rand() % (int)LABS_QUIZ_MAX;
ex1 = rand() % (int)EX1_MAX;
ex2 = rand()% (int)EX2_MAX;
ex3 = rand()% (int)EX3_MAX;
finalEx = rand()% (int)FINAL_EX_MAX;
project = (rand()% (int)PROJECT_MAX);
/* Calculate the overall course grade & convert it to the appropriate letter grade */
//Calculates the percentage marks
participationPer = ((participation / PARTICIPATION_MAX) * PARTICIPATION);
assignmensPer = ((assignmens / ASSIGNMENTS_MAX) * ASSIGNMENTS);
homeworkPer = ((homework / HOMEWORK_CHALLENGES_MAX) * HOMEWORK_CHALLENGES);
labQuizPer = ((labQuiz/ LABS_QUIZ_MAX) * LABS_QUIZ);
ex1Per = ((ex1/ EX1_MAX) * EX1);
ex2Per = ((ex2/ EX2_MAX) * EX2);
ex3Per = ((ex3/ EX3_MAX) * EX3);
finalExPer = ((finalEx/ FINAL_EX_MAX) );
projectPer = ((project/ PROJECT_MAX));
//Calculates the letter grade
participationGrade = getGrade(participationPer);
assignmensGrade = getGrade(assignmensPer);
homeworkGrade = getGrade(homeworkPer);
labQuizGrade = getGrade(labQuizPer);
ex1Grade = getGrade(ex1Per);
ex2Grade = getGrade(ex2Per);
ex3Grade = getGrade(ex3Per);
finalExGrade = getGrade(finalExPer);
projectGrade = getGrade(projectPer);
// Output the users name, their grade for each individual category, and overall grade(number and letter) in the course.
cout<<" First Name: "<<firstName;
cout<<" Last Name: "<<lastName;
cout<<" Participation Percentage: "<<participationPer * 100;
cout<<" Participation Grade: "<<participationGrade;
cout<<" Assignment Percentage: "<<assignmensPer* 100;
cout<<" Assignment Grade: "<<assignmensGrade;
cout<<" Home Work Percentage: "<<homeworkPer* 100;
cout<<" Home Work Grade: "<<homeworkGrade;
cout<<" Lab Quiz Percentage: "<<labQuizPer* 100;
cout<<" Lab Quiz Grade: "<<labQuizGrade;
cout<<" Examination One Percentage: "<<ex1Per* 100;
cout<<" Examination One Grade: "<<ex1Grade;
cout<<" Examination Two Percentage: "<<ex2Per* 100;
cout<<" Examination Two Grade: "<<ex2Grade;
cout<<" Examination Three Percentage: "<<ex3Per* 100;
cout<<" Examination Three Grade: "<<ex3Grade;
cout<<" Final Examination Percentage: "<<finalExPer* 100;
cout<<" Final Examination Grade: "<<finalExGrade;
cout<<" Project Percentage: "<<projectPer* 100;
cout<<" Project Grade: "<<projectGrade;
return 0;
}//End of main method
Sample Run1:
Enter the first and last name of the student: Pyari
Sahu
First Name: Pyari
Last Name: Sahu
Participation Percentage: 2.9
Participation Grade: F
Assignment Percentage: 0.9
Assignment Grade: F
Home Work Percentage: 6.2
Home Work Grade: D
Lab Quiz Percentage: 3.15
Lab Quiz Grade: F
Examination One Percentage: 4.1
Examination One Grade: F
Examination Two Percentage: 1.9
Examination Two Grade: F
Examination Three Percentage: 4.2
Examination Three Grade: F
Final Examination Percentage: 10
Final Examination Grade: A
Project Percentage: 18
Project Grade: A
Sample Run2:
Enter the first and last name of the student: Mohan
Sahu
First Name: Mohan
Last Name: Sahu
Participation Percentage: 6.1
Participation Grade: D
Assignment Percentage: 8.2
Assignment Grade: B
Home Work Percentage: 3.4
Home Work Grade: F
Lab Quiz Percentage: 12.15
Lab Quiz Grade: A
Examination One Percentage: 8
Examination One Grade: B
Examination Two Percentage: 0.4
Examination Two Grade: F
Examination Three Percentage: 5
Examination Three Grade: F
Final Examination Percentage: 82
Final Examination Grade: A
Project Percentage: 93
Project Grade: A
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.