Write a C++ program to determine a student's grade. It reads three test scores (between 0 and 100) and calculates the
average score and converts it to a letter grade.

Grade Conversion Rules:
rule a. If the average score is 90 or more the grade is 'A'.

rule b. If the average score is 70 or more and less than 90 then check the third test score. If the third score is 90 or more
the grade is 'A' otherwise the grade is 'B'.

rule c. If the average score is 50 or more and less than 70 then check the average of the second and third scores. If the
average of the last two is 70 or more, the grade is 'C' otherwise it is a 'D'

rule d. If the average score is less than 50 then the grade is 'F'.

Rounding Rule: Midpoint Rounding
Calculate the grade average as a double. Round up to the next int if the fractional part is .5 or greater, otherwise
truncate the fraction by casting to an int.
The algorithm is: Add .5 to the average and cast the result to an int.
Example: average = (int)(average+0.5);

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

int main()
{
    //variable declarations
    double t1, t2, t3, avg;



    //Input
    cout << "Enter in three test grades that the sudent received:\n";
    cin >> t1, t2, t3;

    //Process
    avg = (t1 + t2 + t3) / 3;

    //Output
    if (avg >= 0)
    {


        if (avg >=90)
        {
            cout << "The student's average is an A:\n" << avg << endl;
        }
        else if (70 <= avg >= 89)
        {
            cout << "The student's average is a B:\n" << avg << endl;
        }
        else if (50 <= avg >= 69)
        {
            cout << "The student's average is a C:\n" << avg << endl;
        }
        else (avg <= 49)
        {
            cout << "The student's average is a F:\n" << avg << endl;
        }


    }
    else
        cout << "The test scores cannot be less than 0. Please enter 0 or more." << endl;

    system("pause");
    return 0;
}

I need help. At this point, I do not know what I am doing. I can guess that my if statements are screwed, but I don't know how to fix them.
Please help.

Thank you.

cin >> t1 >> t2 >> t3 I know that it seems like an unintuitive way to get 3 values from input, but it makes sense once you learn about istreams and the fact that cin is one.

That did not help. Not working =/

You have your signs wrong. You also don't use the and (&&) operator.. You're also missing an if statement to make it an else if. Other than that, your code would have been fine with Labdabeta's correction.

#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    //variable declarations
    double t1, t2, t3, avg;


    //Input
    cout << "Enter in three test grades that the sudent received:\n";
    cin >> t1 >> t2 >> t3;

    //Process
    avg = (t1 + t2 + t3) / 3;

    //Output
    if (avg >= 0)
    {
        if (avg >= 90)
        {
            cout << "The student's average is an A:\n" << avg << endl;
        }
        else if (avg >= 70 && avg <= 89)
        {
            cout << "The student's average is a B:\n" << avg << endl;
        }
        else if (avg >= 50 && avg <= 69)
        {
            cout << "The student's average is a C:\n" << avg << endl;
        }
        else if (avg <= 49)
        {
            cout << "The student's average is a F:\n" << avg << endl;
        }
    }
    else
        cout << "The test scores cannot be less than 0. Please enter 0 or more." << endl;

    system("pause");
    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.