if ((major1 == "computer") && (major2 == "science") && (gpa >= 3.5)) {
cout << "Enter your major: " << major1 << " " << major2 << endl;
cout << "Enter your gpa: " << gpa << endl;
cout << "I think you go to grad school to get a PhD in CS." << endl;
}
else if ((major1 == "computer") && (major2 == "science") && (gpa >= 3.0) && (gpa < 4.0)) {
cout << "Enter your major: " << major1 << " " << major2 << endl;
cout << "Enter your gpa: " << gpa << endl;
cout << "I think you should get an MS in CS while working in the field." << endl;
}
else if ( (major1 == "computer") && (major2 == "science") && (gpa < 3.0)){
cout << "Enter your major: " << major1 << " " << major2 << endl;
cout << "Enter your gpa: " << gpa << endl;
cout << "There are a lot of amazing jobs in CS." << endl;
}
else if ((major1 == "business") && (HELP, HOW TO SEE IF MAJOR2 INPUT IS MISSING, OR NULL, OR NOT THERE) && (gpa > 3.3) {
cin >> gpa;
cout << "Enter your major: " << major1 << endl;
cout << "Enter your GPA: " << gpa << endl;
}
return 0;
}
HELP, HOW TO SEE IF MAJOR2 INPUT IS MISSING, OR NULL, OR NOT THERE............ THE CIN INPUT METHOD IS TRIPPING ME UP, IF I INPUT THEM IN ONE LINE, IE... CIN >> MAJOR1, MAJOR2; THEN IT WILL WORK FOR SOME, BUT NOT ALL INPUTS. SHORTENING THE INPUT FROM 2 WORDS (COMPUTER SCIENCE) TO (BUSINESS) ALTERS THE INPUT METHOD. I NEED HELP TO FIND WORKAROUND... I HAVE READ EVERYTHING, AND I HAVE MUCH MORE WORK TO DO ON OTHER THINGS, PLEASE POINT ME IN THE RIGHT DIRECTION, I KNOW ITS SOMETHING SIMPLE.... THANK YOU.
Really, someone respond. I posed an easy question... the input expects 2 strings (major1 and major2) If the major2 is not entered, then the program does not logic correctly. If major1 is inputed as "computer" and major2 is inputted as "science" then it successfully triggers first if condition. If I then enter major1 and "business" BUT CAN NOT ENTER SECOND VARIABLE, major 2, so only major1 is entered as well as gpa... then the logic fails. I am not sure what to do. I need the last if statment to compare major1 then either recognize major2 is empty or something, and then compare acceptable gpa, and then do what I ask it to do. HOW DO I COMPARE FOR AN EMPTY INPUT? IS THERE ANOTHER WAY TO INPUT.... i was looking at getline, but no luck... please help.
cin >> major1;
cin >> major2;
cin >> gpa;
if ((major1 == "computer") && (major2 == "science") && (gpa >= 3.5)) {
cout << "Enter your major: " << major1 << " " << major2 << endl;
cout << "Enter your gpa: " << gpa << endl;
cout << "I think you go to grad school to get a PhD in CS." << endl;
}
Shouldn't you cin after you've asked to enter your major?
Really, someone respond. I posed an easy question...