fuyoh13
Active Member
- Messages
- 2,165
- Joined
- Apr 19, 2008
- Messages
- 2,165
- Reaction score
- 17
- Points
- 25
senang je nie...
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
bab mana yang tak belajar lagi
senang je nie...
#include<stdio.h>
#include<conio.h>
void main ()
{
int status, a, price, n;
printf("\t******************************************\n");
printf("\tWELCOME TO THE BEST OF THE BEST RESTAURANT\n");
printf("\t******************************************\n");
{
printf("Please choose your menu : ");
printf(" ______________________________________");
printf("| Number of unit | Price per unit (RM) |");
printf("|______________________________________|");
printf("| 1 through 4 | 10 |");
printf("| 5 and over | 9 |");
printf(" ______________________________________");
switch (status)
{
case 1 :
printf("-----------------------------------------------------");
printf("| Number of unit | Price per unit (RM) |");
printf("|-------------------------------------------------- |");
printf("| 1 through 4 | 10 |"<<endl;
printf("| 5 and over | 9 |"<<endl;
printf("-----------------------------------------------------");
printf("_____________________________________________________________________________");
printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
printf("-----------------------------------------------------------------------------");
printf("Please enter the amount of unit you wish to purchase : ");
for(a);
if ( a>=1 && a<=4 )
{
price = a * 10;
printf("Status : 1");
printf("Number of units ordered : ");
printf("Total price : RM");
}
else if ( a>=5 )
{
price = a * 9;
printf("Status : 1");
printf("Number of units ordered : ",a);
printf("Total price : RM",price);
}
else
{
printf("Status : 1");
printf("Number of units ordered : ",a);
printf("Invalid number of units.");
}
break;
case 2 :
printf("-----------------------------------------------------");
printf("| Number of unit | Price per unit (RM) |");
printf("|-------------------------------------------------- |");
printf("| 1 through 3 | 15 |");
printf("| 3 through 8 | 14 |");
printf("| 5 and over | 12 |");
printf("-----------------------------------------------------");
printf("_____________________________________________________________________________");
printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
printf("-----------------------------------------------------------------------------");
printf("Please enter the amount of unit you wish to purchase : ");
for(a);
if ( a>=1 && a<=3 )
{
price = a * 15;
printf("Status : 2");
printf("Number of units ordered : ");
printf("Total price : RM",price);
}
else if ( a>=4 && a<=8 )
{
price = a * 14;
printf("Status : 2");
printf("Number of units ordered : ",a);
printf("Total price : RM ",price);
}
else if ( a>=9 )
{
price = a * 12;
printf("Status : 2"<<endl;
printf("Number of units ordered : ",a);
printf("Total price : RM ",price);
}
else
{
printf("Status : 2");
printf("Number of units ordered : ");
printf("Invalid number of units.");
}
break;
default :
printf("Please enter the amount of unit you wish to purchase : ");
for(a);
if (a>=1)
{
printf("Status : ",status);
printf("Number of units orderes : ",a);
printf("Invalid status code.");
}
else
{
printf("Status : ",status);
printf("Number of units orderes : ",a);
printf("Invalid status code."<<endl;
printf("Invalid number of units.");
}
printf("Press: 1 to restart this porgram");
printf(" 2 to proceed with this program");
for;
if (n==1)
{
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<< endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
m++;
}
else if (n==2)
{
m = m - 1000;
}
return 0;
}
budak ump ker? ak dlu kne jgak. tpi pakai c++.
nie ak tlong sket. yg ak punye projek dlu laa.
try laa run kt matlab.
budak ump ker? ak dlu kne jgak. tpi pakai c++.
nie ak tlong sket. yg ak punye projek dlu laa.
try laa run kt matlab.
error la bro klu bkk kt matlab :">
clc;
clear all;
count = 1;
AmountDue = 0;
moredrink = 'Y';
while moredrink == 'Y'
disp('1: Hot Drink RM1.00');
disp('2: Cold Drink RM1.00');
disp('3: Exit');
reply = input('Please choose 1,2,3 :', 's');
if reply == '1'
AmountDue = AmountDue + 1;
sugarreply = input('Do you want to add sugar? Y/N : ', 's');
sugarreply = upper(sugarreply);
if sugarreply == 'Y'
AmountDue = AmountDue + 0.5;
end
milkreply = upper(input('Do you want to add milk? Y/N [Y]: ', 's'));
if milkreply == 'Y'
AmountDue = AmountDue + 0.5;
end
elseif reply == '2'
AmountDue = AmountDue + 1;
sugarreply = upper(input('Do you want to add sugar? Y/N : ', 's'));
if sugarreply == 'Y'
AmountDue = AmountDue + 0.5;
end
milkreply = input('Do you want to add milk? Y/N [Y]: ', 's');
milkreply = upper(milkreply);
if milkreply == 'Y'
AmountDue = AmountDue + 0.5;
end
else
break;
end
moredrink = upper(input('More Drink to order Y/N : ', 's'));
if moredrink == 'Y'
count = count + 1;
if count > 3
disp('You choose maximum order');
moredrink = 'N';
end
end
end
fprintf('Total Price = %2.2f\n', AmountDue);
yang ini code tanpa function dan tanpa error checking
Code:clc; clear all; count = 1; AmountDue = 0; moredrink = 'Y'; while moredrink == 'Y' disp('1: Hot Drink RM1.00'); disp('2: Cold Drink RM1.00'); disp('3: Exit'); reply = input('Please choose 1,2,3 :', 's'); if reply == '1' AmountDue = AmountDue + 1; sugarreply = input('Do you want to add sugar? Y/N : ', 's'); sugarreply = upper(sugarreply); if sugarreply == 'Y' AmountDue = AmountDue + 0.5; end milkreply = upper(input('Do you want to add milk? Y/N [Y]: ', 's')); if milkreply == 'Y' AmountDue = AmountDue + 0.5; end elseif reply == '2' AmountDue = AmountDue + 1; sugarreply = upper(input('Do you want to add sugar? Y/N : ', 's')); if sugarreply == 'Y' AmountDue = AmountDue + 0.5; end milkreply = input('Do you want to add milk? Y/N [Y]: ', 's'); milkreply = upper(milkreply); if milkreply == 'Y' AmountDue = AmountDue + 0.5; end else break; end moredrink = upper(input('More Drink to order Y/N : ', 's')); if moredrink == 'Y' count = count + 1; if count > 3 disp('You choose maximum order'); moredrink = 'N'; end end end fprintf('Total Price = %2.2f\n', AmountDue);