Soalan 1
MESIN TIN MINUMAN (SWITCH...CASE)
*****************
MESIN TIN MINUMAN
-----------------
1- PEPSI
2- COCA COLA
3- F&N MIRINDA
4- F&N ORANGE
5- 100 PLUS
*****************
Enter your drink:
Enter your money (RM):
Your drink is __________ and your balance are __________
*If the customer does not enter enough money, asked the customer to insert the money. (if...else)
Soalan 2
CALCULATE (IF...ELSE)
CALCULATE:
a) RECTANGULAR
b) TRIANGLE
c) CIRCLE
d) FAHRENHEIT
e) CELCIUS
Your Selection:
Your Selection is _________ and you are calculate _________. The answer is _____________
setiap group kena buat 2 soalan yg diberi oleh miss. miss beri bagi masa smpi ko 12 lebih bagi menyiapkan soalan diatas. bagi group nas faris sedaya-upaya menyiapkan 2 soalan yg diberikn oleh miss. selepas siap dan di check oleh miss ade beberapa kesalahan yg dilakukan oleh group nas. tapi miss tidak memberi jawapan bagi soalan 1 dan 2. Sbb miss nk suwh students buat dulu baru miss bagi jawapan yg betul. sebeleum mengakhiri class miss ingat melihat jawapan soalan 1 dan 2 di minggu depan.
Jawapan Soalan 1
#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;
}
Tiada ulasan:
Catat Ulasan