Can anyone look at my code and explain what I could be doing wrong with this if else statement. No matter how I configure the order I continue to get an error telling my that I have an If without an else statement.I have tried doing it outside a while loop and the incrementation is also not working for me. Also is there anyway to perform an If statement with a string variable and if so how would I need to grab the user's input value and run it through a control statement. Thanks in advance for any help.
#include <iostream>
#include <string>
using namespace std;
class Date
{
public:
void setPayDate(string name)
{
userPayDate = name;
}
string getPayDate()
{
return userPayDate;
}
private:
string userPayDate;
};//end class Date
int main()
{
using namespace std;//Using Namespace library
int userIntChoice = 0;
int loop1 = 1;//declaration variable for loop
Date myDate1;//Creating object from Date class
string userInput = "No Pay";//Default value for user input
cout << "Do you get paid (1)weekly or (2)biweekly? ";
cin >> userIntChoice;
Hint: You forgot to use set braces or curly braces. :)
I took your example and it worked after i used curly braces. I wont show you the code. Do it on your own.
tolower only works for chars. Use #include <algorithm> and transform(str1.begin(), str1.end(), str2.begin(), tolower) where str1 is where the original string is and str2 is where the string is going. Hint: They can be the same string. Then it's if(str2 == "weekly){}