Question
. if/else if Statements: Consider the following code // This program prints You Pass if a student's average is // 60 or higher and prints
. if/else if Statements: Consider the following code
// This program prints "You Pass" if a student's average is
// 60 or higher and prints "You Fail" otherwise
// PLACE YOUR NAME HERE
#include
using namespace std;
int main()
{
float average; // holds the grade average
cout << "Input your average:" << endl;
cin >> average;
if (average > 60)
cout << "You Pass" << endl;
if (average < 60)
cout << "You Fail" << endl;
return 0;
}
Exercise 1: Run the program three times using 80, 55 and 60 for the average. What happens when you input 60 as the average? Modify the first if statement so that the program will also print You Pass if the average is greater than or equals 60.
Exercise 2: Modify the program so that it uses an if/else statement rather than two if statements.
Exercise 3: Modify the program from Exercise 2 to allow the following categories:
Invalid data (data above 100),
A category (90100),
B category (8089),
You Pass category (6079),
You Fail category (059).
What will happen to your program if you enter a negative value such as -12?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started