Question: C ++ please Lab 2 Enter the following program: double average; cout < < Input your average: ; cin >> average; if (average > 60)
C ++ please
Lab 2
Enter the following program:
double average;
cout << "Input your average: ";
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 for the average? Modify the first if statement so that the program will print "You pass" if the average is 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 (average above 100), 'A' category (90-100), 'B' category (80-89), "You pass" category (60-79), and "You fail" category (0-59). 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
