im making an if else statement program determining the eligibility of an applying student. my output for student - 2 keeps saying "wow!is this for real?We would love to have you at UNA... blah blah"
cout << "Hello! Please enter your student classification: " << endl;
cout << "High school graduate-1" << endl << "Transfer student-2" << endl << "Current UNA student-3" << endl;
cin >> stdntClass;
{
if (stdntClass == 1)
{
cout << "Congrats! Please enter your GPA here: ";
cin >> gpa;
cout << "And your ACT score here: ";
cin >> act;
}
if (gpa >= 3.0 || act >= 24 )
{
cout << "Wow! Is this for real?";
}
else
{
cout << "Sorry, it appears your GPA and ACT scores do not meet UNA requirements.";
}
}
{
if (stdntClass == 2)
{
cout << "We would love to have you here at UNA! please enter your current GPA here: ";
cin >> gpa;
}
if (gpa >= 3.0)
{
cout << "Wow! is this for real?";
}
else
{
cout << "Sorry, it appears your GPA does not meet UNA requirements.";
Some formatting & indentation would not hurt either
Posting ALL of your code as a Short, Self Contained, Correct (Compilable), Example (http://www.sscce.org/) sure wouldn't hurt either. Without code tags or more code it is hard to say what the problems might be.
#include <iostream>
usingnamespace std;
int main()
{
int studentClass{0};
double gpa{0}, act{0};
cout
<< "Hello! Please enter your student classification:\n"
<< " High school graduate-1\n"
<< " Transfer student-2\n"
<< " Current UNA student-3\n";
cin >> studentClass;
if (studentClass == 1)
{
cout << "Congrats! Please enter your GPA here: ";
cin >> gpa;
cout << "And your ACT score here: ";
cin >> act;
}
if (gpa >= 3.0 || act >= 24 )
{
cout << "Wow! Is this for real?";
}
else
{
cout << "Sorry, it appears your GPA and ACT scores do not meet UNA requirements.";
}
if (studentClass == 2)
{
cout << "We would love to have you here at UNA! please enter your current GPA here: ";
cin >> gpa;
}
if (gpa >= 3.0)
{
cout << "Wow! is this for real?";
}
else
{
cout << "Sorry, it appears your GPA does not meet UNA requirements.";
}
return 0;
}
@OP
I tidied up your code and made it a complete program. With all due respect, it presents as a logical mess. The if ... else statements don't appear to make sense. No amount of guessing and quick fixing will achieve much if anything for you.
However, as a starting tip my guess is you should be asking the user for the course, gpa and act only once. Maybe also the approval/rejection decision only depends on the gpa and act?
What you need to do is:
1. Post the original question.
2. Write some pseudocode and then and only then ...
3. Write/debug code based on that.