If and Else troubles

I have to write a code to calculate a final grade for our class and it asks a few questions about your grades then it calculates. The problem lies that is if you take more than 2 quizzes then the code is suppose to drop two of the quizzes, but it's not and I think it has something to do with my "If" code.

When using this line if (quizsum < 2){, I ask it to calculate the final grade with only 2 quiz scores and it gets it right, but when I try it with say like 5 quiz scores it doesn't even ask me about the lowest 2 scores?

Here's the rest of the code. Please don't be too hateful on the repetitiveness/simplicity of the clue, it's only my 2nd week in the course.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include <iomanip>
#include <math.h>

int main()
{
    using namespace std;
   // NAMEING VARIABLES
    double programaverage;
    double programaveragefixed;
    double test_points_sum;
    double testaveragefixed;
    double testpointspossible;
    int quizzes_taken;
    int quizsum;
    int quizsumlow;
    double testaverage;
    double finalgrade;
    
    //ASKING USER ABOUT COURSE SCORES
    cout << "Enter Program Average Score:  ";
    cin >> programaverage;
    cout << "Enter sum of the Test Scores:  ";
    cin >> test_points_sum;
    cout << "Enter Maximum test points available:";
    cin >> testpointspossible;
    cout << "Enter the number of quizzes that have been taken:";
    cin >> quizzes_taken;
    cout << "Enter the sum of all of the quiz points:";
    cin >> quizsum;
    
    if (quizsum < 2){
    cout << "Enter the scores of the lowest 2 quiz scores:";
        cin >> quizsumlow;}
    


    
// FORMULA FOR GETTING TEST SCORE
    if (quizsum < 2){
        testaverage =(test_points_sum + quizsum - quizsumlow) / (testpointspossible + (10 * (quizzes_taken - 2))) * 100.0;
    }else{
        testaverage =(test_points_sum + quizsum) / (testpointspossible + (10 * quizzes_taken)) * 100;}
    
    
// FINDING OUT OVERALL SCORE
    programaveragefixed = 35 * programaverage / 100;
    testaveragefixed = 65.0 * testaverage / 100;
    
    finalgrade = programaveragefixed + testaveragefixed;
   
 // OUTPUT
    cout << setprecision(4) << "********************\n  Grade Calculator\n";
    cout << setprecision(4) << "Program Average   ";
    cout << setprecision(4) << programaverage;
    cout << setiosflags(ios::fixed)<< setprecision(2) << "\nTest Average      ";
    cout << setprecision(2) << testaverage;
    cout << setprecision(4) << "\n \nFinal Grade       ";
    cout << setprecision(2) << finalgrade;
    cout << setprecision(4) << "\n********************";
    
    
    
    return 0;
}
replace if (quizSum < 2 ) with if (quizSum > 2) .
1
2
3
4
5
6
7
8
9
10
11
12
if (quizsum < 2)
{
    cout << "Enter the scores of the lowest 2 quiz scores:";
    ...
}

// Substitute 5 for quizsum
if (5 < 2)
{
    cout << "Enter the scores of the lowest 2 quiz scores:";
    ...
}


Now, do you understand why it does not ask about the lowest two scores?
Okay so I went through and replace the first If statement from if (quizsum < 2) to if (quizsum > 2) but now whenever I try that the code then asks the user about the lowest quiz scores if they only have 2 quizzes.
Firstly, you also need to replace the second if with if (quizSum > 2) .

About your program asking you for "Enter the scores of the lowest 2 quiz scores: when you enter quisSum = 2 , its not possible.

I ran the code with those changes and it didnt ask me to enter the lowest scores when i used 2.
whenever I try that the code then asks the user about the lowest quiz scores if they only have 2 quizzes.

That is probably because quizsum is not the the amount of tests taken.
1
2
3
4
cout << "Enter the number of quizzes that have been taken:";
cin >> quizzes_taken;
cout << "Enter the sum of all of the quiz points:";
cin >> quizsum;
thanks, that's what was wrong.
Topic archived. No new replies allowed.