variables, data types, and numerical operators
basic input/output
logic (if statements, switch statements)
Write a program that presents the user w/ a choice of your 5 favorite beverages
(Coke, Water, Sprite, ... , Whatever).
Then allow the user to choose a beverage by entering a number 1-5.
Output which beverage they chose.
? If you program uses if statements instead of a switch statement, modify it to
use a switch statement. If instead your program uses a switch statement, modify
it to use if/else-if statements.
?? Modify the program so that if the user enters a choice other than 1-5 then
it will output "Error. choice was not valid, here is your money back."
*/
#include <iostream>
enum Beverage
{
PEPSI = 1,
SPRITE,
ORANGE_JUICE,
WATER,
RED_BULL,
};
void WhichBeverage(Beverage eBeverage)
{
using namespace std;
switch(eBeverage)
{
case 1:
cout << "You chose Pepsi." << endl;
break;
case 2:
cout << "You chose Sprite." << endl;
break;
case 3:
cout << "You chose orange juice." << endl;
break;
case 4:
cout << "You chose water." << endl;
break;
case 5:
cout << "You chose Red Bull." << endl;
break;
cout << "Error. Choice was not valid, here is your money back." << endl;
}
}
int main()
{
using namespace std;
cout << "Please select your beverage. Press:" << endl;
cout << " 1 for Pepsi" << endl;
cout << " 2 for Sprite" << endl;
cout << " 3 for orange juice" << endl;
cout << " 4 for water" << endl;
cout << " 5 for Red Bull" << endl;
Beverage eBeverage;
cin >> eBeverage; // ovdje javlja gresku (no match for 'operator>>' in 'std::cin >> eBeverage')
WhichBeverage(eBeverage);
system("pause");
return 0;
}