Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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