I am fairly new to C++, as you can probably tell from the difficulty, or lack of, of this program.Code://This program illustrates the use of logical operators #include <iostream> 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; }
I need to know how to make the line in bold work correctly using the NOT operator, I have exhausted all options I can think of and can't seem to get the program to work correctly.
-Ryan



LinkBack URL
About LinkBacks



For example, the condition in the 'else if' is exactly the opposite of the condition in the 'if' block (note that these conditions are copied and pasted from your own code!):