This lab introduces the logical operators AND, OR, and NOT in a menu driven appl
ID: 3567138 • Letter: T
Question
This lab introduces the logical operators AND, OR, and NOT in a menu driven application program
if ( gpa >= 2.0 && year == '4') with
if ( gpa >= 2.0 || year == '4') and replace
else if ( year != '4'|| gpa < 2.0) with
else if ( year != '4' && gpa < 2.0)
which students will graduate and which will not graduate according to this new program? Does this handle all cases (i.e., all combinations of year and gpa)?
The following is the code to be used:
// This program illustrates the use of logical operators
// PLACE YOUR NAME HERE
#include
using namespace std;
int main()
{
char year;
float gpa;
cout << "What year student are you ?" << endl;
cout << "Enter 1 (freshman), 2 (sophomore), 3 (junior), or 4 (senior)" << endl << endl;
cin >> year;
cout << "Now enter your GPA" << endl;
cin >> gpa;
if (gpa >= 2.0 && year == '4')
cout << "It is time to graduate soon" << endl;
else if (year != '4'|| gpa <2.0)
cout << "You need more schooling" << endl;
return 0;
// Please highlight any changes you made and reasoning for changes. I will reward the person who has a high answer rating and reward them if they are correct.
PLEASE INSERT SOLUTION INTO CODE TO REPRESENT HOW THE CODE WILL LOOK LIKE IF THE QUESTION WAS APPLIED TO THE PROGRAM.
Explanation / Answer
!(gpa < 2.0)
Yes. It will anyway execute because gpa<2 will always be true if gps>=2 is false and else if will execute. So changing year won't effect.
Students with gpa greater than 2 and year equal to 4 will graduate. Yes it handles all scenarios.
Yes. It doesn't make sense to have this condition because if condition 1 fails then this will always be true.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.