- #1

carl123

- 56

- 0

20% Homeworks (out of 80 points)

30% Midterm exam (out of 40 points)

50% Final exam (out of 70 points)

Suggested (incremental) steps to finish the program:

First run it.

Next, complete the midterm exam calculation and run the program again. Use the constant variables where appropriate.

Then, complete the final exam calculation and run the program. Use the constant variables where appropriate.

Modify the program to include a quiz score out of 20 points. New weights: 10% homework, 15% quizzes, 30% midterm, 45% final. Run the program again.

To avoid having one large expression, introduce variables homeworkPart, quizPart, midtermPart, and finalPart. Compute each part first; each will be a number between 0 and 1. Then combine the parts using the weights into the course value.

Run the program again.

#include <iostream>

using namespace std;

int main() {

const double HOMEWORK_MAX = 80.0;

const double MIDTERM_MAX = 40.0;

const double FINAL_MAX = 70.0;

const double HOMEWORK_WEIGHT = 0.20; // 20%

const double MIDTERM_WEIGHT = 0.30;

const double FINAL_WEIGHT = 0.50;

double homeworkScore = 0.0;

double midtermScore = 0.0;

double finalScore = 0.0;

double coursePercentage = 0.0;

cout << "Enter homework score:" << endl;

cin >> homeworkScore;

cout << "Enter midterm exam score:" << endl;

cin >> midtermScore;

cout << "Enter final exam score: " << endl;

cin >> finalScore;

coursePercentage = ((homeworkScore / HOMEWORK_MAX) * HOMEWORK_WEIGHT)

+ 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;

return 0;

}