Vous êtes sur la page 1sur 51

CONTENT

Content…..…………………………………………………………………………………1

A1……………………………………………………………………..………………..….2
 Pseudocode…………… .……………………………..……….……………...…...3
 Flowchart………………………………………………………………………...………..4
 Code…………………………………………………………………...…….…5 - 9
 Ouput………………………………………………………………………….…..10

A2……………………………………………………………………………………..…..11
 Pseudocode………………...……………………………………………………...12
 Flowchart………………………………………………………………………….13
 Code…………………………………………………………………...…….14 - 18
 Ouput…………………………………………………………………..……19 - 20

A3…………………………………………………….………………….………..………21
 Pseudocode……………………………………………………………………….22
 Flowchart…………………………………………………………………………23
 Code………………………………………………………………………...24 - 28
 Ouput………………………………………………………………………

A4…………………………………………………………………………………………31
 Pseudocode………………………………………………………………….........32
 Flowchart………………………………………………………………………….33
 Code…………………………………………………………………………34 - 37
 Ouput………………………………………………………………………...38 - 39

A5…………………………………………………………………………………..………40
 Pseudocode………………………………………………………….…...………..41
 Flowchart………………………………………………………………………….42
 Code………………………………………………………...………………..43 - 49
 Ouput…………………………………………………………………..………….50

Bibliography……………………………………..………………………………..…...… 51

1
A1

2
PSEUDOKOD

1. Start

2. Input…Select Order

3. If 1…(Small), 2…(Medium), 3...(Large)

3.1. Change Drink…..

3.1.1. If Yes…

3.1.1.1. Output….Additional Price RM1.00(Small), RM1.50(Medium),

RM2.00(Large).

3.1.2. Else….

3.1.2.1. Output….Price RM3.00(Small), RM3.50(Medium),

RM4.00(Large)

4. Else…

4.1. End

3
FLOWCHART

Start

Input order

No
Select Order

Yes

Order 1
Order 2
Ordert 3

Change drink No
Print Price

Yes

Additional Price

Print Price

Calculate Sum

Output Print Sum

End

CODE
4
#include<stdio.h>

main()

int order;

int change;

int small=3;

int large=4;

float medium=3.5;

char next_order;

printf("WELCOME TO NURI CHICKEN RICE RESTAURANT\n");

printf("----------------------------------------\n");

printf("\n");

printf("Our meal set consists of:\n");

printf("-Roasted Chicken\n");

printf("-Rice\n");

printf("-Soya Sauce\n");

printf("-Chilli Sauce\n");

printf("-Chicken Soup\n");

printf("-Mixed Salad\n");

printf("-Carbonated Drink\n");

printf("\n");

printf("*****************Size of Meal Set******************\n");

5
printf("\n");

printf("Small (1), Medium (2), large(3)\n");

printf("\n");

printf("Which one do you like to buy?\n");

scanf("%d",&order);

fflush(stdin);

switch (order)

case 1:

printf("Small order");

printf("\n");

printf("price RM 3.00 \n");

printf("\n");

printf("Do you want to change your drink to Fruit Juice? Y/N: \n");

scanf("%c",&next_order);

if (next_order =='y')

change = small + 1;

printf("Please Pay :RM %d\n",change);

printf("\n");

printf("*********THANK YOU & COME AGAIN**********");

6
else

printf("Please Pay RM 3.00\n");

printf("\n");

printf("********THANK YOU & COME AGAIN**********");

break;

case 2 :

printf("Medium Order");

printf("\n");

printf("Price RM3.50\n");

printf("\n");

printf("Do you want to change your drink to Fruit Juice? Y/N: \n");

scanf("%c",& next_order);

if (next_order =='y')

change = medium + 1.5;

printf("Please Pay :RM %d\n",change);

printf("\n");

printf("*********THANK YOU & COME AGAIN*********");

else

7
{

printf("Please Pay RM3.50");

printf("\n");

printf("********THANK YOU & COME AGAIN*********");

break;

case 3 :

printf("Large Order \n");

printf("\n");

printf("Price RM 4.00\n");

printf("\n");

printf("Do you want to change your drink to Fruit Juice? Y/N:\n");

scanf("%c",& next_order);

if (next_order =='y')

change = large+ 2;

printf("Please pay :RM %d\n",change);

printf("\n");

else

printf("Please Pay RM4.00\n");

8
printf("\n");

default :

printf("*********Thank You And Come Again*********\n");

9
OUTPUT

WELCOME TO NURI CHICKEN RICE RESTAURANT

----------------------------------------

Our meal set consists of:

-Roasted Chicken

-Rice

-Soya Sauce

-Chilli Sauce

-Chicken Soup

-Mixed Salad

-Carbonated Drink

*****************Size of Meal Set******************

Small (1), Medium (2), large(3)

Which one do you like to buy?

Medium Order

Price RM3.50

Do you want to change your drink to Fruit Juice? Y/N:

Please Pay :RM 5

*********THANK YOU & COME AGAIN*********

10
A2

11
PSEUDOKOD

1. Start

2. Select Order

3. If 1…(Small), 2…(Medium), 3...(Large)

4.1. Change Drink…..

4.1.1. If Yes…

4.1.1.1. Output….Additional Price RM1.00(Small), RM1.50(Medium),

RM2.00(Large).

4.1.2. Else….

4.1.2.1. Output….Price RM3.00(Small), RM3.50(Medium), RM4.00(Large)

4. Else…

4.1. Go to Line 3…

5. New Order

5.1. if Yes…..Go to line 3….

5.2. If No….

5.2.1. Calculate Total Sum…

6. Output

6.1. Printf Total Sum…

7. End

12
FLOWCHART

Start

Input order

No Select Order

Yes
Order 1
Order 2
Ordert 3

Change drink
No
Print Price

Yes
Additional Price

Print Price

Next Order
Yes

No

Calculate Sum

Output Print Sum

End
13
CODE

#include<stdio.h>

main()

int order;

int set=1;

int small=3;

int large=4;

float sum;

int num;

double total;

float medium=3.5;

char next_order;

total=0;

printf("***************Welcome to Nuri Chicken Restaurant****************\n");

printf("~Please Make Your Order\n");

printf("\n");

printf("How Many order You Want?\n");

scanf("%d",&num);

printf("\n");

printf("**********Size of Meal Set********\n");

14
printf("Small (1), Medium (2), Large (3)\n");

printf("\n");

while (set<=num)

printf("Which one do you like to buy?\n");

scanf("%d",&order);

fflush(stdin);

switch (order)

case 1:

printf("Small order");

printf("\n");

printf("Price RM3.00\n");

printf("\n");

printf("Do you want to change your drink to Fruit Juice? y/n:\n");

scanf("%c",&next_order);

if (next_order =='y')

sum=small+1;

printf("Price is : RM%.2f\n",sum);

printf("\n");

15
}

else

sum=small;

printf("Price is: RM%.2f\n",sum);

printf("\n");

break;

case 2:

printf("Medium order");

printf("\n");

printf("Price RM3.50\n");

printf("\n");

printf("Do you want to change your drink to Fruit Juice? y/n:\n");

scanf("%c",&next_order);

if (next_order =='y')

sum=medium+1.5;

printf("Price is : RM%.2f\n",sum);

printf("\n");

else

16
{

sum=medium;

printf("Price is: RM%.2f\n",sum);

printf("\n");

break;

case 3:

printf("Large order");

printf("\n");

printf("Price RM4.00\n");

printf("\n");

printf("Do you want to change your drink to Fruit Juice? y/n:\n");

scanf("%c",&next_order);

if (next_order =='y')

sum=large+2;

printf("Price is : RM%.2f\n",sum);

printf("\n");

else

sum=large;

17
printf("Price is: RM%.2f\n",sum);

printf("\n");

break;

num--;

total+=sum;

printf("Total Price is:RM%.2f\n",total);

printf("***THANK YOU & COME AGAIN***\n");

printf("\n");

18
OUTPUT

**************Welcome to Nuri Chicken Restaurant****************

~Please Make Your Order

How Many order You Want?

**********Size of Meal Set********

Small (1), Medium (2), Large (3)

Which one do you like to buy?

Small order

Price RM3.00

Do you want to change your drink to Fruit Juice? y/n:

Price is : RM4.00

Total Price is:RM4.00

***THANK YOU & COME AGAIN***

19
Which one do you like to buy?

Medium order

Price RM3.50

Do you want to change your drink to Fruit Juice? y/n:

Price is : RM5.00

Total Price is:RM9.00

***THANK YOU & COME AGAIN***

Which one do you like to buy?

Large order

Price RM4.00

Do you want to change your drink to Fruit Juice? y/n:

Price is : RM6.00

Total Price is:RM15.00

20
***THANK YOU & COME AGAIN***

A3

21
PSEUDOCODE

1. Start

2. Select Order

3. If 1…(Small), 2…(Medium), 3...(Large)

3.1. Change Drink…..

3.1.1. If Yes…

3.1.1.1. Output….Additional Price RM1.00(Small), RM1.50(Medium),

RM2.00(Large).

3.1.2. Else….

3.1.2.1. Output….Price RM3.00(Small), RM3.50(Medium), RM4.00(Large)

4. Else…

4.1. Go to Line 3…

5. New Order

5.1. If Yes…. Go to Line 3…

5.2. If No…Calculate Sum..

6. Output Calculate Sum

7. End

22
FLOWCHART

Start

Input order

No Select Order

Yes
Order 1
Order 2
Ordert 3

Change drink
No
No
PrintPrice
Print Price

Yes
Yes
Additional Price

Print Price

NextOrder
Next Order
Yes
Yes

No
No
CalculateSum
Calculate Sum

OutputPrint
Output PrintSum
Sum

23

End
End

CODE

#include<stdio.h>

order()

int order;

int num=1,next_order;

int small=3;

int large=4;

float sum;

double total;

float medium=3.5;

char change_drink;

total=0;

printf("~Please Make Your Order\n");

printf("\n");

printf("How Many order You Want?\n");

scanf("%d",&next_order);

printf("\n");

24
while (num<=next_order)

printf("Which one do you like to buy?\n");

scanf("%d",&order);

fflush(stdin);

switch (order)

case 1:

printf("Small order");

printf("\n");

printf("Price RM3.00\n");

printf("\n");

printf("Do you want to change your drink to Fruit Juice? Y/N:\n");

scanf("%c",&change_drink);

if (change_drink =='y')

sum=small+1;

printf("Price is : RM%.2f\n",sum);

printf("\n");

else

25
sum=small;

printf("Price is: RM%.2f\n",sum);

printf("\n");

break;

case 2:

printf("Medium order");

printf("\n");

printf("Price RM3.50\n");

printf("\n");

printf("Do you want to change your drink to Fruit Juice? Y/N:\n");

scanf("%c",&change_drink);

if (change_drink =='y')

sum=medium+1.5;

printf("Price is : RM%.2f\n",sum);

printf("\n");

else

sum=medium;

printf("Price is: RM%.2f\n",sum);

26
printf("\n");

break;

case 3:

printf("Large order");

printf("\n");

printf("Price RM4.00\n");

printf("\n");

printf("Do you want to change your drink to Fruit Juice? Y/N:\n");

scanf("%c",&change_drink);

if (change_drink =='y')

sum=large+2;

printf("Price is : RM%.2f\n",sum);

printf("\n");

else

sum=large;

printf("Price is: RM%.2f\n",sum);

printf("\n");

27
break;

next_order--;

total+=sum;

printf("Total Price is:RM%.2f\n",total);

printf("***THANK YOU & COME AGAIN***\n");

printf("\n");

return next_order;

void main()

printf("*************Welcome to Nuri Chicken Restaurant***************\n");

printf("\n");

printf("**********Size of Meal Set********\n");

printf("Small (1) RM3.00 :Additional RM1.00 to change drink\n");

printf("Medium (2) RM3.50 :Additional RM1.50 to change drink \n");

printf("Large (3) RM4.00 :Additional RM2.00 to change drink\n");

printf("\n");

order();

28
}

OUTPUT

***************Welcome to Nuri Chicken Restaurant****************

**********Size of Meal Set********

Small (1) RM3.00 :Additional RM1.00 to change drink

Medium (2) RM3.50 :Additional RM1.50 to change drink

Large (3) RM4.00 :Additional RM2.00 to change drink

~Please Make Your Order

How Many order You Want?

Which one do you like to buy?

Small order

Price RM3.00

Do you want to change your drink to Fruit Juice? Y/N:

Price is: RM3.00

29
Total Price is:RM3.00

***THANK YOU & COME AGAIN***

Which one do you like to buy?

Medium order

Price RM3.50

Do you want to change your drink to Fruit Juice? Y/N:

Price is : RM5.00

Total Price is:RM8.00

***THANK YOU & COME AGAIN***

Which one do you like to buy?

Large order

Price RM4.00

Do you want to change your drink to Fruit Juice? Y/N:

Price is: RM4.00

Total Price is:RM12.00

30
***THANK YOU & COME AGAIN***

A4

31
PSEUDOCODE

1. Start

2. Select Order

3. If 1…(Small), 2…(Medium), 3...(Large)

3.1. Change Drink…..

3.1.1. If Yes…

3.1.1.1. Output….Additional Price RM1.00(Small), RM1.50(Medium),

RM2.00(Large).

3.1.2. Else….

3.1.2.1. Output….Price RM3.00(Small), RM3.50(Medium), RM4.00(Large)

5. Else…

5.1. Go to Line 3…

6. New Order

6.1. If Yes…. Go to Line 3…

6.2. If No…Calculate Sum..

7. Output 10 Orders….

8. Output Calculate Sum Orders….

9. End

32
FLOWCHART

Start

Input order

No
No Select Order

Yes
Yes
Order 1
Order 2
Ordert 3

Change drink No
No
Print Price

Yes
Yes
Additional Price

Print Price

Next Order
Yes
Yes

No
Print Selected Order

Calculate Sum
33
Output Print Sum

End

CODE

#include<stdio.h>

order()

int order;

int set=1;

int set_order;

int small=3;

int large=4;

float medium=3.5;

double sum[10],j,total;

char change_drink;

total=0;

printf("\n");

printf("Quantity order you request:");

scanf("%d",&set_order);

printf("\n");

34
while(set<=set_order)

printf("\n");

printf("Type Your Order here : ");

scanf("%d",&order);

fflush(stdin);

switch (order)

case 1:

printf("Change Drink to Fruit Juice? Y/N: ");

scanf("%c",&change_drink);

if(change_drink=='y')

sum[j]=small+1;

printf("Price : RM%.2f\n",sum[j]);

else

sum[j]=small;

printf("Price : RM%.2f\n",sum[j]);

break;

35
case 2:

printf("Change Drink to Fruit Juice? Y/N: ");

scanf("%c",&change_drink);

if(change_drink=='y')

sum[j]=medium+1.5;

printf("Price : RM%.2f\n",sum[j]);

else

sum[j]=medium;

printf("Price : RM%.2f\n",sum[j]);

break;

case 3:

printf("Change Drink to Fruit Juice? Y/N: ");

scanf("%c",&change_drink);

if(change_drink=='y')

sum[j]=large+2;

printf("Price : RM%.2f\n",sum[j]);

36
}

else

sum[j]=large;

printf("Price : RM%.2f\n",sum[j]);

break;

set_order--;

total+=sum[j];

printf("\n");

printf("Total Price: RM%.2f\n",total);

printf("*****Thank You & Come Again*****\n");

printf("\n");

return total;

void main()

printf("*******Nuri Chicken Restaurant*******\n");

printf(" RECEIPT \n");

printf("***********Enjoy Your Meal***********\n");

printf("\n");

37
order();

OUTPUT

***********Enjoy Your Meal***********

Quantity order you request:10

Type Your Order here : 1

Change Drink to Fruit Juice? Y/N: y

Price : RM4.00

Type Your Order here : 2

Change Drink to Fruit Juice? Y/N: y

Price : RM5.00

Type Your Order here : 3

Change Drink to Fruit Juice? Y/N: y

Price : RM6.00

Type Your Order here : 1

Change Drink to Fruit Juice? Y/N: n

Price : RM3.00

38
Type Your Order here : 2

Change Drink to Fruit Juice? Y/N: n

Price : RM3.50

Type Your Order here : 3

Change Drink to Fruit Juice? Y/N: n

Price : RM4.00

Type Your Order here : 1

Change Drink to Fruit Juice? Y/N: y

Price : RM4.00

Type Your Order here : 2

Change Drink to Fruit Juice? Y/N: n

Price : RM3.50

Type Your Order here : 3

Change Drink to Fruit Juice? Y/N: n

Price : RM4.00

Type Your Order here : 1

Change Drink to Fruit Juice? Y/N: y

Price : RM4.00

Total Price: RM41.00

39
*****Thank You & Come Again*****

A5

40
PSEUDOCODE

1. Start

2. Input Employee Details

3. Select Order

4. If 1…(Small), 2…(Medium), 3...(Large)

4.1. Change Drink…..

4.1.1. If Yes…

4.1.1.1. Output….Additional Price RM1.00(Small), RM1.50(Medium),

RM2.00(Large).

4.1.2. Else….

4.1.2.1. Output….Price RM3.00(Small), RM3.50(Medium), RM4.00(Large)

5. Else…

5.1. Go to Line 3…

6. New Order

6.1. If Yes…. Go to Line 3…

6.2. If No…Calculate Sum..

7. Output 10 Orders….

8. Output Calculate Sum Orders….

9. Output Employee Information

41
10. Calculate the highest collected

11. Save in file

12. Output the highest collected result

13. End

FLOWCHART
Start

Input Employee Details

Input order

No
Select Order

Yes

Order 1
Order 2
Ordert 3

Change drink No
Print Price

Yes
Additional Price

Print Price

Next Order
Yes

No
Print Selected Order

Calculate Sum 42

Output Print Sum


Stored Data
Employee

CODE

#include<stdio.h>

#include<string.h>

#include<stdlib.h>

#include<conio.h>

#define MAX 10

main()

FILE*fp;

fp=fopen("cashierRank.dat","w");

int order,employeeNum;

char name;

int set=1;

int set_order;

int small=3;

int large=4;

float medium=3.5;

double sum[10],j,total;

43
char change_drink;

total=0;

printf("****************************\n");

printf("NURI CHICKEN RICE RESTAURANT\n");

printf("____________________________\n");

printf("Employee Number: "); scanf("%d",&employeeNum);

putw(employeeNum,fp);

printf("Employee Name: "); scanf("%s",&name);

putc(name,fp);

fflush(stdin);

printf("\n");

printf("Quantity order you request:");

scanf("%d",&set_order);

printf("\n");

while(set<=set_order)

printf("\n");

printf("Type Your Order here : ");

scanf("%d",&order);

fflush(stdin);

44
{

switch (order)

case 1:

printf("Change Drink to Fruit Juice? Y/N: ");

scanf("%c",&change_drink);

if(change_drink=='y')

sum[j]=small+1;

printf("Price : RM%.2f\n",sum[j]);

else

sum[j]=small;

printf("Price : RM%.2f\n",sum[j]);

break;

case 2:

printf("Change Drink to Fruit Juice? Y/N: ");

scanf("%c",&change_drink);

if(change_drink=='y')

45
{

sum[j]=medium+1.5;

printf("Price : RM%.2f\n",sum[j]);

else

sum[j]=medium;

printf("Price : RM%.2f\n",sum[j]);

break;

case 3:

printf("Change Drink to Fruit Juice? Y/N: ");

scanf("%c",&change_drink);

if(change_drink=='y')

sum[j]=large+2;

printf("Price : RM%.2f\n",sum[j]);

else

sum[j]=large;

printf("Price : RM%.2f\n",sum[j]);

46
break;

set_order--;

total+=sum[j];

printf("\n");

printf("Total Price: RM%.2f\n",total);

printf("*****Thank You & Come Again*****\n");

printf("\n");

putw(total,fp);

fclose(fp);

return 0;

worker();

struct CashierNuri

int employeeNum;

char name[20];

double TotalCollect;

} employee;

47
typedef struct CashierNuri Teller;

Teller Cashier[5];

worker()

FILE*fp;

fp =fopen ("cashierRank.dat","w");

int j,h;

int num;

char name[20];

double TotalCollect,collected;

if(!fp)

return 1;

for(j=1;j<=5;j++)

scanf("%d",&employee.employeeNum);

fprintf(fp,"%d\n",&employee.employeeNum);

for(j=1;j<=5;j++)

48
scanf("%d",&employee.name);

fprintf(fp,"%d\n",&employee.name);

for(j=1;j<=5;j++)

scanf("%.2f",&employee.TotalCollect);

fprintf(fp,"%.2f\n",&employee.TotalCollect);

fprintf(fp,">>>>>Information of Cashier with the highest collection<<<<<\n");

fprintf(fp,"*Employee Num : %d\n",employee.employeeNum);

fprintf(fp,"*Employee Name : %s\n",employee.name);

fprintf(fp,"*Total Collected : %.2f\n",employee.TotalCollect);

fclose(fp);

return 0;

49
OUTPUT

Employee Num :1

Employee Name : Jainah

Total Collected (RM) : 45.00

Employee Num :2

Employee Name : Norazlina

Total Collected (RM) : 25.00

Employee Num :3

Employee Name : Michelle

Total Collected (RM) : 35.00

Employee Num :4

Employee Name : Jasnieza

Total Collected (RM) : 47.00

Employee Num :5

Employee Name : Chung

Total Collected (RM) : 28.00

>>>>> Information of cashier with the highest collection<<<<<

50
*Employee Num :4

*Employee Name : Jasnieza

*Total Collected (RM): 47.00

BIBLIOGRAPHY

 “Menguasai Bahasa C” by Hung Jiin Kwei.

 “C for DUMMIES “2nd EDITION by Dan Gookin.

 http://en.wikipedia.org/wiki/C_(programming_language)

 “THE PROGRAMMING LANGUAGE” by Brian W.Kernighan and Dennis Ritchie.

 http://www.cprogramming.com/

 http://www.suite101.com/content/c-tutorial-file-handling-commands-a20756

 http://personal.ee.surrey.ac.uk/Personal/R.Bowden/C/fileops.html

51

Vous aimerez peut-être aussi