You are on page 1of 11

UNIVERSITI TUN HUSSEIN ONN MALAYSIA

FACULTY OF MECHANICAL AND MANUFACTURING


ENGINEERING
BDA 24202
COMPUTER PROGRAMMING
INDIVIDUAL ASSIGNMENT

NAME: WONG HANG SING


MATRIC NO: AD180234
SECTION: 7
LECTURER’S NAME: DR. HO FU HAW

1
1.0 Problem Statement

From this figure, it show a burger stall which many people patronize. As the figure shown,
this burger stall only got 1 people to order and make burger. This make the customer need to
wait for a long time to order their burger and the staller may not recognise the type of burger
order by the customer because there are many type of burger. This condition make the
customer complain this burger stall because wait a long time to get a wrong type of burger.

1.1 Problem’s solution


In order to solve this problem, a burger ordering system is indeed for this burger stall. If got
the burger ordering system, the customer can order the burger more quickly and the staller
can recognise the order better. Besides that, he also can add the drinks in the burger ordering
system to make the customer has more choice at his stall. In this burger ordering system, the
type of burgers is divided into three types which are chicken, beef and fish burger. The
customer also can add some requirement likes extra cheese and the size of the drink and fries.
Then, this system also can calculate the price of the customer’s order.

2
2.0 Flow Chart
Start

Read
burgerOrder

Read
burgerPackage

Choose
burgerPackage
(1 or 2)

BurgerPacka BurgerPack
ge==1 age==2

Read burgerType
and extra cheese

Read
BurgerT burgerT burgerT ComboTy
ype==1 ype==2 ype==3 pe,
softDrink
and
extraChe
ese
totalPrice1= totalPrice1=
3.00+(0.80*e totalPrice1=5.
3.00+(0.80*e
xtraCheese)c 00+(0.80*extr
xtraCheese)
hickenBurger aCheese)fishB
beefBurger+
++ urger++
+

B
A

3
B

totalPrice1=3.00+(0.80
*extraCheese)+1 ComboT
chickenBurger++ ype==1

totalPrice1=3.00+(0.80
ComboTy
*extraCheese)+1
pe==2
beefBurger++

totalPrice1=5.00+(0.8
ComboT
0*extraCheese)+1
ype==3
fishBurger++

Read
burgerOrd
er,chickenB
totalPrice = urger,beef
A totalPrice + Burger,fish
totalPrice1 Burger and
totalPrice

Display
Order
Details

End

4
3.0 Algorithm
Step 1: Start
Step 2: Read burgerOrder
Step 3: Read burgerPackage
Step 3.1: - If burgerPackage==1, to step4
- If burgerPackage==2 to step6
- else, back to step 3
Step 4: Read burgerType and extraCheese
Step 4.1: - If burgerType==1, totalPrice1=3.00+(0.80*extraCheese)
- If burgerType==2, totalPrice1=3.00+(0.80*extraCheese)
- If burgerType==3, totalPrice1=5.00+(0.80*extraCheese)
- Else, invalid input
Step 5: Go to A
Step 6: Read ComboType, softDrink and extraCheese
Step 7: Go to B
Step 8: - If ComboType==1, totalPrice1=3.00+(0.80*extraCheese)+1
- If ComboType==2, totalPrice1=3.00+(0.80*extraCheese)+1
- If ComboType==3, totalPrice1=5.00+(0.80*extraCheese)+1
Step 9: Go to A
Step 10: Calculate totalPrice = totalPrice + totalPrice 1
Step 11: Read burgerOrder,chickenBurger,beefBurger,fishBurger and totalPrice
Step 12: Display Order Details
Step 13: End

5
4.0 C-codes
#include <stdio.h>

int main()
{
//Declare variable
int repeat;
int burgerOrder;
int burgerPackage;
int burgerType;
int extraCheese;
int ComboType;
int chickenBurger = 0;
int beefBurger = 0;
int fishBurger = 0;
int softDrink;
double totalPrice = 0;
double totalPrice1;
//User input to order burger
printf("Enter the number of burger you like to order:\t");
scanf("%d", &burgerOrder);
fflush(stdin);
do
{
for(repeat = 1; repeat <= burgerOrder; repeat++)
{
do
{
printf("Burger %d:\n", repeat);

//Ala carte or combo


printf("Enter the following number to select your
burger package: (1 - Ala carte, 2 - Combo): ");
scanf("%d", &burgerPackage);

6
fflush(stdin);

//Ala carte selection


if(burgerPackage == 1)
{
printf("Enter the following number to
choose you burger type:(1 - Chicken Burger, 2 - Beef Burger, 3 - Fish Burger): ");
scanf("%d", &burgerType);
fflush(stdin);

printf("Enter the number of extra


cheese you want to add. If you don't want extra cheese, please enter 0: ");
scanf("%d", &extraCheese);
fflush(stdin);
do
{
//Chicken Burger
if(burgerType == 1)
{
totalPrice1 = 3.00 +
(0.80 * extraCheese);
//For order detail
chickenBurger++;
}

//Beef burger
else if (burgerType == 2)
{
totalPrice1 = 3.00 +
(0.80 * extraCheese);
//For order detail
beefBurger++;
}

7
//Fish burger
else if (burgerType == 3)
{
totalPrice1 = 5.00 +
(0.80 * extraCheese);
//For order detail
fishBurger++;
}

//Invalid input
else
{
printf("Invalid
input.\n");
}

}
while(burgerType != 1 &&
burgerType != 2 && burgerType != 3);
}

//Combo selection
else if (burgerPackage == 2)
{
printf("Enter the following number to
choose you burger type:(1 - Chicken Burger, 2 - Beef Burger, 3 - Fish Burger): ");
scanf("%d", &ComboType);
fflush(stdin);

printf("Enter the following number to


choose your soft drink:(1 - Cola, 2 - Sprite, 3 - Orange): ");
scanf("%d", &softDrink);

8
printf("Enter the number of extra
cheese you want to add. If you don't want extra cheese, please enter 0: ");
scanf("%d", &extraCheese);
fflush(stdin);

do
{
//Chicken burger
if(ComboType == 1)
{
totalPrice1 = 3.00 +
(0.80 * extraCheese) + 1;
chickenBurger++;
}

//Beef burger
else if (ComboType == 2)
{
totalPrice1 = 3.00 +
(0.80 * extraCheese) + 1;
beefBurger++;

//Fish burger
else if (ComboType == 3)
{
totalPrice1 = 5.00 +
(0.80 * extraCheese) + 1;
fishBurger++;
}

//Invalid Input
else

9
{
printf("Please enter
between 1-3 only.\n");
}
}
while(ComboType != 1 &&
ComboType != 2 && ComboType != 3);

}
else
{
printf("Please enter 1 or 2.\n");
}
}
while(burgerPackage != 1 && burgerPackage != 2);

//Calculation for total price


totalPrice = totalPrice + totalPrice1;
}
}
while(burgerOrder == 0);
//Show Order Details
printf("Order Details:\n");
printf("Total burger order: %d\n", burgerOrder);
printf("Chicken burger: %d\n", chickenBurger);
printf("Beef burger: %d\n", beefBurger);
printf("Fish burger: %d\n", fishBurger);
printf("Total Price: %.2f\n", totalPrice);
return 0;
}

10
5.0 Sample Run of the Program

11

You might also like