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

## Expert Answer

** **

/*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>

#include <string.h>

using namespace std;

string grade(int score){

if(score<40){

return “F”;

}

else if(score<43){

return “C-“;

}

else if(score<46){

return “C”;

}

else if(score<50){

return “C+”;

}

else if(score<55){

return “B-“;

}

else if(score<60){

return “B”;

}

else if(score<65){

return “B+”;

}

else if(score<70){

return “A-“;

}

else if(score<80){

return “A”;

}

else{

return “A+”;

}

return “Some issue in getting grade”;

}

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;

//Assigning weightage to all the scores according to the grading scale given at the end

const double PARTICIPATION = .10;

const double ASSIGNMENTS = .0; //No weightage given to assignments

const double HOMEWORK_CHALLENGES = .10;

const double LABS_QUIZ = .15;

const double EXAM1 = .10; //Dividing tests weightage of 30%(or .3) equally between the 3 exams

const double EXAM2 = .10;

const double EXAM3 = .10;

const double FINAL_EXAM = 0.15;

const double PROJECT = 0.20;

// Have the user input their first and last name as a single input

string name;

cout<<“Please enter your full name like John Doe: “;

getline(cin,name); //This will take the full name including whitespace max character as 50

/* 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. */

int seed;

cout<<endl<<“Enter the value of seed: “;

cin>>seed; //Enter 7 if you want seed to be 7 as given in the comments

srand(seed);/*Giving the same value of seed in srand will generate the

same set of numbers when we use rand function*/

int participationScore=rand()%100;

int assignmentScore=rand()%100;

int homeworkScore=rand()%100;

int labquizScore=rand()%100;

int exam1Score=rand()%50+50;

int exam2Score=rand()%50+50;

int exam3Score=rand()%50+50;

int finalExamScore=rand()%100;

int projectScore=rand()%100;

/* Calculate the overall course grade & convert it to the appropriate letter grade */

/* Calculating the coursePercentage as the weighted score of all the scores*/

double coursePercentage = (participationScore / PARTICIPATION_MAX) * PARTICIPATION +

(assignmentScore / ASSIGNMENTS_MAX) * ASSIGNMENTS +

(homeworkScore / HOMEWORK_CHALLENGES_MAX) * HOMEWORK_CHALLENGES +

(labquizScore / LABS_QUIZ_MAX) * LABS_QUIZ +

(exam1Score / EXAM1_MAX) * EXAM1 +

(exam2Score / EXAM2_MAX) * EXAM2 +

(exam3Score / EXAM3_MAX) * EXAM3 +

(finalExamScore / FINAL_EXAM_MAX) * FINAL_EXAM +

(projectScore / PROJECT) * PROJECT;

//Do not multiply with 100 to get %age as the weights are in fractions and not in percentages

cout << endl << “Your course percentage: “;

cout << coursePercentage << endl;

// Output the users name, their grade for each individual category, and overall grade(number and letter) in the course.

cout<<endl<<“YOUR name: “<<name<<endl; //Output the users name

cout<<endl<<“Your Perormance: “;

/* Output the various scores and their corresponding grades.

For grades we call the function grade() which takes the score and returns the grade*/

cout<<endl<<“PARTICIPATION SCORE: “<<participationScore<<“tPARTICIPATION GRADE: “<<grade(participationScore);

cout<<endl<<“ASSIGNMENTS SCORE: “<<assignmentScore<<“tASSIGNMENTS GRADE: “<<grade(assignmentScore);

cout<<endl<<“HOMEWORK CHALLENGES SCORE: “<<homeworkScore<<“tHOMEWORK CHALLENGES GRADE: “<<grade(homeworkScore);

cout<<endl<<“LABS QUIZ SCORE: “<<labquizScore<<“tLABS QUIZ GRADE: “<<grade(labquizScore);

cout<<endl<<“EXAM1 SCORE: “<<exam1Score<<“tEXAM1 GRADE: “<<grade(exam1Score);

cout<<endl<<“EXAM2 SCORE: “<<exam2Score<<“tEXAM2 GRADE: “<<grade(exam2Score);

cout<<endl<<“EXAM3 SCORE: “<<exam3Score<<“tEXAM3 GRADE: “<<grade(exam3Score);

cout<<endl<<“EXAMFINAL SCORE: “<<finalExamScore<<“tEXAMFINAL GRADE: “<<grade(finalExamScore);

cout<<endl<<“PROJECT SCORE: “<<projectScore<<“tPROJECT GRADE: “<<grade(projectScore);

cout<<endl<<“OVERALL SCORE: “<<coursePercentage<<“tOVERALL GRADE: “<<grade(coursePercentage);

return 0;

}

//Output