Saturday, March 26, 2011
Mesin minuman
#include <iostream.h>
main()
{
//declare
int selection;
float money,balance,price,addm,add;
//out
cout<<"******************"<<endl;
cout<<"Mesin Tin Minuman"<<endl;
cout<<"------------------"<<endl;
cout<<"1.PEPSI";
cout<<"\n2.COCA COLA";
cout<<"\n3.F&N MIRINDA";
cout<<"\n4.F&N ORANGE";
cout<<"\n5.100 PLUS"<<endl;
cout<<"******************"<<endl;
//input
cout<<"\nPlease Choose Your Drink"<<endl;
cin>>selection;
cout<<"\nPlease Enter MONEY: ";
cin>>money;
switch (selection)
{
case 1: cout<<" Your drink is Pepsi";
price = 2.00;
break;
case 2: cout<<" Your drink is Coca Cola";
price = 2.00;
break;
case 3: cout<<" Your drink is F&N Mirinda";
price = 1.80;
break;
case 4: cout<<" Your drink is F&N Orange";
price = 1.80;
break;
case 5: cout<<" Your drink is 100 Plus";
price = 2.50;
break;
default: cout<<"invalid selection";
}
if (money>price)
{
balance = money - price;
}else if (money<price)
{
add = price - money;
cout<<"Please add (RM" <<add<< ")= ";
cin>>addm;
balance = money + addm;
}
cout<<"Your balance is "<<balance;
return 0;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment