TUMING 4
Novella Daria Utami | 1517051135
email: novelladariautami@gmail.com
Question
Requires:
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."
/*
* Hello.cpp
*
* Created on: 20 okt 2015
*
Author: Novella Daria Utami | 1517051135
*/
#include <iostream>
using namespace std;
main(){
int drink;
cout<<"\t\t\t===Hello Welcome Customer==="<<endl;
cout<<"Please Select your Drink..."<<endl;
cout<<"1. CocaCola"<<endl;
cout<<"2. Mineral Water"<<endl;
cout<<"3. Root Beer"<<endl;
cout<<"4. Sprite"<<endl;
cout<<"5. Fanta"<<endl<<endl;
cout<<"Please Enter The Number of Drinks : ";
cin>>drink;
if (drink == 1){
cout<<"CocaCola";
}
else
if (drink == 2){
cout<<"Mineral Water";
}
else
if (drink == 3){
cout<<"Root Beer";
}
else
if (drink == 4){
cout<<"Sprite";
}
else
if (drink == 5){
cout<<"Fanta";
}
else{
cout<<"Error.. Choice Was Not Valid, Her is Your Money Back";}
cout<<"\n\n\t\t\t\tThank You..."<<endl;
return 0;
}
return 0;
}