How to Calculate a Student's Total Course Percentage in C++?

  • Context: C/C++ 
  • Thread starter Thread starter ineedhelpnow
  • Start date Start date
  • Tags Tags
    C++ Functions
Click For Summary

Discussion Overview

The discussion revolves around completing a C++ program designed to calculate a student's total course percentage based on scores from various weighted assessments, including homework, midterm, and final exams. The conversation includes steps for modifying the program and addressing specific calculations.

Discussion Character

  • Homework-related
  • Technical explanation

Main Points Raised

  • One participant shares an incomplete C++ program and outlines incremental steps to finish it, including fixing calculations for the midterm and final exams.
  • The program currently calculates only the homework percentage and has placeholders (FIXME) for the midterm and final exam calculations.
  • Another participant inquires if the first user was able to run the program, indicating a focus on practical execution.
  • A follow-up question prompts the user to address the second step of fixing the midterm calculation, suggesting a collaborative approach to problem-solving.

Areas of Agreement / Disagreement

The discussion does not present any consensus, as participants are in the process of addressing specific steps in the programming task without resolving the overall question of how to complete the program.

Contextual Notes

The program's logic and calculations depend on the correct implementation of the weights and scores, which remain unresolved as participants work through the steps incrementally.

ineedhelpnow
Messages
649
Reaction score
0
The following incomplete program should compute a student's total course percentage based on scores on three items of different weights (%s):
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:
1. First run it.
2. Next, complete the midterm exam calculation and run the program again. Use the constant variables where appropriate.
3. Then, complete the final exam calculation and run the program. Use the constant variables where appropriate.
4. 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.
5. 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.

Code:
#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;
}

i don't understand this question at all! please help!
 
Last edited:
Technology news on Phys.org
Were you able to run the program?
 
Yes
 
Ok, were you able to do the second step, and fix the midterm calculation? (Hint: It's the part in the code that has the first FIXME).
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 49 ·
2
Replies
49
Views
12K
  • · Replies 27 ·
Replies
27
Views
5K
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K