I have to make a program where it prompts the user to input a number between "zero" and "nineteen" and then have it translate it into spanish. If the number is not between zero or nineteen, I need to cout<< a certain statement.
So far this is what I have
//initializing a bunch of strings to equal the translation for that number
//ex: string zero = "cero";
//Then I initialize number to be a string
//Then I have an infinite for loop
//In that for loop I have the following
cout << "Number, please: ";
cin >> number;
if (number == "zero")
{
cout << "In Spanish that is " << zero << '.' << endl;
}
if (number == "one")
{
cout << "In Spanish that is " << one << '.' << endl;
}
if (number == "two")
{
cout << "In Spanish that is " << two << '.' << endl;
}
//I continue this all the way to nineteen
What I'm having trouble with is having a statement that couts if the number they enter isn't zero through nineteen
EDIT: Fixed it!
I changed the if statements to else if, and then the error message was a plain else statement
cout << "Number, please: ";
cin >> number;
if (number == "zero")
{
cout << "In Spanish that is " << zero << '.' << endl;
}
if (number == "one")
{
cout << "In Spanish that is " << one << '.' << endl;
}
if (number == "two")
{
cout << "In Spanish that is " << two << '.' << endl;
}
else
{
cout << "Invalid input " << number;
}