dimanche 3 octobre 2021

my while loops and else if loops dont work

i am trying to have the letter show with the appropriate grade. then i would like the program to ask me over and over my midterm and my final score. then give the appropriate grade for that score as of now it only give me the scores of the first run. here is my code i'm a nub sorry im dumb.

enter code here#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
    int midterm;
    int final;


    cout << "please enter midterm grade: ";
    cin >> midterm;
    while (midterm < 0 || midterm > 200)
    {
        cout << "Please enter valid amount must be 0 or greater or 200 or less. please enter grade: ";
        cin >> midterm;
    }
    cout << " please enter final grade: ";
    cin >> final;
    while (final < 0 || final > 200)
    {
        cout << "Please enter valid amount must be 0 or greater or 200 or less. Please enter grade";
        cin >> final;
    }
    
    int total;
    total = final + midterm;
    cout << "total";

    if (total > 360 || total <=400)
    {
        cout << "your letter grade is A";
    }   
    else if (total > 320 || total < 359)
    {
        cout << "your letter grade is B";
    }
    else if (total > 280 || total < 319)
    {
        cout << "your letter grade is C";
    }
    else if (total > 279 || total < 241)
    {
        cout << "your letter grade is D";
    }
    else if (total < 240)
    {
        cout << "your letter is F";
        
    }
    

}

Aucun commentaire:

Enregistrer un commentaire