### Nobody wants to help?

Been playing around with it, I got the errors to go away but my if else statements aren't working correctly. no matter what the final score is, it goes with the first output. for example, if the score is 200..it outputs: "

"Your total score is 200 and you have a B"
The best possible grade you can get is an A
You need 250 points to do so.

This is incorrect because the output should give the user a F and say he has failed...

#include <iostream>
#include <cmath>
#include<iomanip>
using namespace std;

{
double hw1;
double hw2;
double hw3;
double hw4;
double hw5;
double hw6;
double hw7;
double quiz1;
double quiz2;
double quiz3;
double test1;
double test2;
double ec1;
double ec2;
double ec3;
double ec4;
double ec5;
};

int main() {
double score = 0.0;

cout << "This program will calculate your final grade for the semester" << endl;

cout << "Enter your grade for Homework 1(Range from 0-20): " << endl;
cin >> Sean.hw1;

cout << "Enter your grade for Homework 2(Range from 0-30): " << endl;
cin >> Sean.hw2;

cout << "Enter your grade for Homework 3(Range from 0-30): " << endl;
cin >> Sean.hw3;

cout << "Enter your grade for Homework 4(Range from 0-30): " << endl;
cin >> Sean.hw4;

cout << "Enter your grade for Homework 5(Range from 0-30): " << endl;
cin >> Sean.hw5;

cout << "Enter your grade for Homework 6(Range from 0-30): " << endl;
cin >> Sean.hw6;

cout << "Enter your grade for Quiz 1(Range from 0-20): " << endl;
cin >> Sean.quiz1;

cout << "Enter your grade for Quiz 2(Range from 0-20): " << endl;
cin >> Sean.quiz2;

cout << "Enter your grade for Quiz 3(Range from 0-20): " << endl;
cin >> Sean.quiz3;

cout << "Enter your grade for Test 1(Range from 0-70): " << endl;
cin >> Sean.test1;

cout << "Enter your grade for Test 2(Range from 0-70): " << endl;
cin >> Sean.test2;

cout << "Enter your grade for Extra Credit Assigment 1(Range from 0-20): " << endl;
cin >> Sean.ec1;

cout << "Enter your grade for Extra Credit Assigment 2(Range from 0-20): " << endl;
cin >> Sean.ec2;

cout << "Enter your grade for Extra Credit Assigment 3(Range from 0-20): " << endl;
cin >> Sean.ec3;

cout << "Enter your grade for Extra Credit Assigment 4(Range from 0-20): " << endl;
cin >> Sean.ec4;

cout << "Enter your grade for Extra Credit Assigment 5(Range from 0-20): " << endl;
cin >> Sean.ec5;

score += Sean.hw1 + Sean.hw2 + Sean.hw3 + Sean.hw4 + Sean.hw5 + Sean.hw6 + Sean.quiz1 + Sean.quiz2 + Sean.quiz3 + Sean.test1 + Sean.test2 + Sean.ec1 + Sean.ec2 + Sean.ec3 + Sean.ec4 + Sean.ec5;

cout << "Your total score is " << score << endl;

if(score >= 450){
cout << "You are exempt from the Final Exam" << endl;
}
else {
cout<< "You are not exempt" << endl;

cout<< "Enter your projected grade for Homework 7(Range from (0-30): " << endl;
cin >> Sean.hw7;
score += Sean.hw7;
}
if(score >= 450){
cout << "You are exempt from the Final Exam" << endl;
}
else if (score >= 400 ||score < 450){

cout << "Your total score is " << score << " and you have a B " << endl;
cout << "You are still not exempt " << endl;
cout << "The best possible grade you can get by taking the final is an A " << endl;
cout << "You need " << 450 - score << " more points to do so" << endl;
}

else if (score >= 350 || score < 400){

cout << "Your total score is " << score << " and you have a C " << endl;
cout << "You are still not exempt " << endl;
cout << "The best possible grade you can get by take the final is an A " << endl;
cout << "You need " << 450 - score << " more points to do so." << endl;
}

else if (score >= 300 || score < 350){
cout << "Your total score is " << score << " and you have a D " << endl;
cout << "You are still not exempt " << endl;
cout << "The best possible grade you can get by take the final is a B " << endl;
cout << "You need " << 400 - score << " more points to do so." << endl;
}

else if (score >= 250 || score < 300){
cout << "Your total score is " << score << " and you have a F " << endl;
cout << "You are still not exempt " << endl;
cout << "The best possible grade you can get by take the final is a C " << endl;
cout << "You need " << 350 - score << " more points to do so." << endl;
}

else{
cout << "Your total score is " << score << " and you have a F " << endl;
cout << "You have failed the course.";

}

std::cout << "Press ENTER to continue...";
std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
return 0;
}
how about using a debugger, especially since you have an idea what could be the problem there. also please use codetags "<>"
There's nothing to debug, Im not getting errors. Its just not going to my if else if the first statement isn't true. And I would use them if I knew what it does
One tip, look into arrays.

Have you tried putting parentheses around that massive string of additions?
I'm not really sure where you're saying the error is occurring at, but I would start there.

EDIT:
Your list of if statements, I believe you were wanting the and operator (&&) and not the or operator (||) for all those conditions.
Last edited on
@ResidentBiscuit THANKS!!! I went wrong by putting the OR operator and I mean the And..just haven't used them in so long and got mixed up. I really appreciate it
Did that fix it for ya?
Yupp! Appreciate it!!
Topic archived. No new replies allowed.