C ++ please Lab 2 Enter the following program: double average; cout << \"Input y
ID: 3754371 • Letter: C
Question
C ++ pleaseLab 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? 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?
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? 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?
Explanation / Answer
Exercise 1:
For input 80, program printed You pass
For input 55, program printed You fail
For input 60, program printed nothing
Modified program:
Exercise 2:
Exercise 3:
When a negative number if entered nothing will be printed
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.