Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

////////////////C++ if else statement not working////////////// #include<iostrea

ID: 3849044 • Letter: #

Question

////////////////C++ if else statement not working//////////////

#include<iostream>
using namespace std;

int main()
{
   float GPA; // GPA
   int score; // Test Score

   while (1) // infinite loop
   {
       cout << "Please enter your GPA: "; // GPA input
       cin >> GPA;

       if (GPA == 0.0) // 0.0 to quit
           break;
       cout << "Please enter your entrance score: "; // test score input
       cin >> score;

       if (score = 40 || (score >= 32 && GPA == 3.7)) // score of 40 gets in, high test score and gpa get in
       {
           cout << "Congratulations! You are hereby admitted to ABC Medical University!" << endl;
       }
       else
       {
           cout << "We are sorry! You are hereby denied admission to ABC Medical University." << endl; // rejection statement
       }
   }
       cout << "Thank you for your use of the Admissions Software Program at ABC Medical University" << endl;
}

The program determines whether or not you get accepted to this university. It more or less works. The thing is the rejection statement does not print. No matter what score you enter you get accepted.

Explanation / Answer

Revised Program:

#include<iostream>
using namespace std;
int main()
{
float GPA; // GPA
int score; // Test Score
while (1) // infinite loop
{
cout << "Please enter your GPA: "; // GPA input
cin >> GPA;
if (GPA == 0.0) // 0.0 to quit
break;
cout << "Please enter your entrance score: "; // test score input
cin >> score;
if ((score >= 32 && GPA >= 3.7)) // score of 40 gets in, high test score and gpa get in
{
cout << "Congratulations! You are hereby admitted to ABC Medical University!" << endl;
}
else
{
cout << "We are sorry! You are hereby denied admission to ABC Medical University." << endl; // rejection statement
}
}
cout << "Thank you for your use of the Admissions Software Program at ABC Medical University" << endl;
}

Output:

Please enter your GPA: 6.7 Please enter your entrance score: 40 Congratulations! You are hereby admitted to ABC Medical University! Please enter your GPA: 2.5 Please enter your entrance score: 60 We are sorry! You are hereby denied admission to ABC Medical University. Please enter your GPA: 3.7 Please enter your entrance score: 32 Congratulations! You are hereby admitted to ABC Medical University! Please enter your GPA: 6 Please enter your entrance score: 23 We are sorry! You are hereby denied admission to ABC Medical University. Please enter your GPA: 0 Thank you for your use of the Admissions Software Program at ABC Medical University