I'm new to c++ and im trying to make a program that will allow a user to figure out what Gregory is doing based on the day of the week and other variables.
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main() {
cout << "Find out what Gregory will do today. \n";
string weekday;
cout << "What day of the week is it? \n";
getline (cin,weekday);
if(weekday == "wednesday") {
cout << "It is Wednesday";
}
return 0;
}
I havent fully figured out how to get strings from a user yet so this was my first attempt, but when running the program it allows a user to type a weekday, but doesn't go on to print "It is Wednesday" regardless of user input.
//this code is my second try
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main() {
cout << "Find out what Gregory will do today. \n";
string weekday;
cout << "What day of the week is it? \n";
cin >> weekday;
if(weekday == "wednesday") {
cout << "It is Wednesday";
}
else {
cout << "It's not Wednesday";
}
return 0;
}
In my second try I got frustrated and went back to just using cin to collect input, but with this code, "It's not Wednesday" is printed regardless of user input.