Está en la página 1de 41

DF0971ICT Problem Solving And Program Design Using C

ASIA PACIFIC INSTITUTE OF INFORMATION TECHNOLOGY

Assignment Title

Group Assignment

Module Code and Title

Problem Solving and Problem Design Using C (AAPP005-3-2-PSPD)

Intake Code

DF0971ICT

Submitted By

Don Ashan Madhawa Dhanapala (CB003190)

Sahan Madusanka (CB003532)

Submitted To

Mr. Udesh Amarasinghe

Date Assigned

27th July 2009

Date Due

7th September 2009

1
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

Table of Contents

Table of Contents ....................................................................................................................... 2

Acknowledgments...................................................................................................................... 3

Introduction ................................................................................................................................ 4

Objectives .............................................................................................................................. 4

Scope ...................................................................................................................................... 4

Project Description..................................................................................................................... 5

Flowcharts .................................................................................................................................. 8

User Guide ............................................................................................................................... 12

Limitations ............................................................................................................................... 18

Further Development ............................................................................................................... 19

Conclusion ............................................................................................................................... 20

Appendices ............................................................................................................................... 21

Gantt Chart ........................................................................................................................... 21

Source Code ......................................................................................................................... 22

Work Breakdown Structure ................................................................................................. 40

Agreed Work Percentage ..................................................................................................... 40

References ............................................................................................................................ 41

2
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

Acknowledgments

We would like to thank Mr. Udesh Amarasinghe for his continuous support and guidance in
the preparation of this project. Without his valuable supervision, all our efforts could have
been short-sighted.

Mr. Udesh Amarasinghe and our friend Asanka, Asia Pacific Institute of Information
Technology, helped us with various issues during the project and we are grateful to them. We
are also obliged to Charindra Wijemanna for her help during our project. Besides, a number
of friends had always been around to support us morally. We would like to thank them as
well.

We owe quite a lot to our parents who provided us the chance to fulfill our career objectives
and for the support throughout our studies. We would like to dedicate this project to them as
an indication of their significance in this project as well as in our lives.

Finally, we are responsible for any errors that remain in this project documentation.

3
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

Introduction

Objectives
The main objective of this project is to create a billing and payment processing system to
pizza hut using C programming language.

This program should be able to,

 Accept orders.
 Print a detailed bill indicating pizzas and beverages which the customers have
purchased.
 Printout any discounts which the customer received.
 Exit the program.

Also this program is able to discard any order which is placed by the user.

Scope
The scope of this project is to evaluate our knowledge in C prgramming and to evaluate
problem solving capabilities by using C programming.

We are supposed to use below amenities in C to complete our project.

 Good logic in programming.


 Structures.
 Arrays.
 Loops.
 Decision structures.
 Files.

And also we advised to you use any extra features we may feel relevant to the system.

4
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

Project Description

We coded this program using various IDE’s such as

 Microsoft Visual Studio 2008


 Turbo C++
 Notepad++

And to compile we used the Borland compiler which is provided in the Turbo C++ IDE.

We coded the program to function in very simple way. Most common inputs the program is,

 Numbers.
 Y and N.

We used two files in this program. Billing.h header file and the c main file. We created
billing.h file to store,

 Destinations
 Function prototypes.
 Global variables
 Initializations of the arrays.
 And some functions to return values to the main c file.

In the main c file, above file is included as a header. By using a separate header,

 It will short programming code in the main file.


 And if another programmer going to edit this program, it will be easier to him or her
to understand the front end of the programming code.
 And a good programming practice.

Also we used ctype.h header file to uppercase of the decision inputs (Y/N) from the user.
Because inputs are case sensitive in. But using this (toupper), the user no longer has to worry
about entering upper case or lower case inputs. The program will take that as uppercase
character and it will execute as it is programmed to.

5
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

We used functions in the programming as much as we could.

 void mainMenu( ); - To display main menu


 void orderMenu( ); - To display order menu
 void pizzaOrder( ); - To display pizza order menu
 void bevrgOrder( ); - To display beverage order menu
 void discardOrder( ); - This function will clear the arrays which is currently used.
 void viewOrder( ); - To display detailed bill
 void confirmOrder( ); - To confirm order and to do calculate the grand total.

Main menu options.

 To place orders.
 To exit.

Order menu options.

 Add pizzas.
 Add beverages.
 View order.
 Confirm order.
 Discard order.

Pizza order menu options.

 Pizza type ID.


 Size of the pizza.
 Quantity.
 Add more pizzas.

Beverage order menu options.

 Beverage type ID.


 Quantity.
 Add more beverages.

6
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

View order menu options

 Press any key to return to order menu.

Confirm order menu options.

 Pay by Master/Visa – Y or No
 Grand total
 Press any key to return to the main menu.

From the menu (mainMenu function) if the user enters 1, the program will execute the
orderMenu functions and it will display the order menu. After that corrospondendly if the
user enters 1 to add pizzas or 2 to add beverages these fucntions will be executed from the
program.

 pizzaOrder
 bevrgOrder

After completing placing orders the user will return back to the order menu which the user
can,

 add more items.


 view order.
 confirm order.

Maximum capacity of item-orders to be placed is four. If it exceeds the capacity it will


display an error message.

If the enters 4 as the input to the system, viewOrder function will be executed.

If the user 5 as the input to the system, confirmOrder function will be executed.

In the confirmOrder function after completing order the program will return back to the
main menu. (Arrays will be cleared for a new order to place)

Any windows based system can run this program without any issues.

7
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

Flowcharts
void mainMenu( ); - To display main menu

8
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

void orderMenu( ); - To display order menu

9
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

void pizzaOrder( ); - To display pizza order menu

10
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

Billing.h char *getNameTag ();

11
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

User Guide
Main Menu

Main menu of the program has a simple interface. It has two options. One is to place orders
and the other one is to exit or terminate the program.

After entering each significant command and pressing enter key will execute each input
from the user.

When the user enters 1 as the input, the program will display the order menu of the program.

In the order menu, the user will have three options.

1. To add pizzas to the order


2. To add beverages to the order
3. Discard the order.

By selecting discard order the program will return to the main menu. And the user can start
from the beginning.

12
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

If the user enters 1 as the input to the program, the program will display the pizza ordering
menu to the user.

13
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

Or if the user enters 2 as the input to the program, it will display the beverages menu to the
user.

If the user enters the pizza menu or beverages menu, program will ask these questions to
place an order.

Pizza menu

 Type of the pizza.


 Size of the pizza.
 Quantity to be purchased.
 And to add more pizzas to the order to discard the order.

Beverages Menu

 Type of the beverage.


 Quantity to be purchased.
 And to add more beverages to the order or to discard the order.

14
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

Pizza Menu

Beverages Menu

15
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

After placing the orders the program will return back to the order menu. Now in the order
menu, there are two new options.

 View order
If the user selects the option called view order the, program will display a detailed bill
of purchased goods. After pressing any key the program will return back to the order
menu.

 Confirm order
If the user selects the option called confirm order, the program will display the detail
bill with asking the user to enter the way of payment which the specific customer
going to use.

Pay by Master/Visa – Y or N

If the order is more than 2500 plus if the customer going pay by Master/Visa card, the
customer going received a 10% discount.

Else no discount will be given to the user.

16
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

After pressing any key the program will return to main menu which will display to place an
order and to exit the system.
From the main menu the user can redo the above procedure over and over again without any
limitations.

But only four items can be placed to an order each time. If the customer needs more
than four item-orders, the user has to confirm and finish the current order and has to
place a new order for the other items which the customer wants to purchase.

17
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

Limitations

When developing this programmed some issues raised up.

No data is saved for future references.

 After completing an order the arrays will be cleared. Therefore no data or logs are
saved of the purchased goods. Due that reason the user cannot track any past
transactions.

Lengthiness of the coding.

 We had to use two files for programming because the program coding became
extended. Due to the lengthiness of the coding it’s hard to recode or do future
modifications to the program.

Compiling with Borland compiler.

 We used Borland compiler to compile our code. Sometimes it gave errors which we
could not understand to debug.

No hardcopy of the bill is printed.

 Due to our lack of knowledge in C programming we did not know how to print a
hardcopy from the printer of the detail bill.

User interface

 Our program user interface has a command driven interface. This might have some
issues with the user when regarding the user friendliness.

18
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

Further Development

Some further developments can be done to this program.

Printing a hardcopy of the detail bill.

 A hardcopy of the bill can be printed to handover to the customer as receipt of the
transaction.

Saving backups and logs of each transaction.

 All the transaction logs can be saved in a database for future referencing and auditing.
But now in this program data is saved in to the main memory which is volatile.

Making a better user interface.

 C is not an object oriented programming language. Its a procedural programming


language. If we use VB.net or C++, we could make a better interface with icons and
pictures which will be easier to understand by the user.

User logins.

 User names and passwords can be given to each user to login to the program.
Therefore the program can track what each user did in his or her current logged
period.

19
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

Conclusion

We used this opportunity evaluate our logical knowledge and programming knowledge in c
while covered over a cloud of errors which we faced in coding.

We got to know how to filter out what we can do in C and what we cannot. We tried put
codes and execute which is extra to the basic requirements. But some worked and many
failed.

The main thing we learnt through this project is to handle frustration and stress while we
getting countless amount of errors. But we were able to overcome them. After successfully
coding the basic requirements we moved forward to putting extra functions which we
enjoyed coding. We learnt how to include a header file which we created and it executed
successfully. We learnt what are the good programming practices and not.

Finally seeing an error free executable program which we created by ourselves and putting
more than expected from the assignment to the program is overwhelmingly satisfying.

20
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

Appendices

Gantt Chart

21
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

Source Code
Billing.h

#include <stdio.h>

// Definistions

#define PIZZA_SMALL 0.6


#define PIZZA_REG 1.0
#define PIZZA_LARGE 1.8

#define SIZE_SMALL 0
#define SIZE_REG 1
#define SIZE_LARGE 2
#define SIZE_NONE 3

#define DISCOUNT 0.1

#define HC "Hong Kong Chicken"


#define DC "Devilled Chicken"
#define SD "Sausage Delight "
#define SV "Spicy Vege "
#define CO "Cheesy Onion "
#define IT "Italian Tomato "

#define CC "Coca Cola "


#define GB "Ginger Beer"
#define IC "Ice Cofee "

#define SS "SMALL"
#define SL "LARGE"
#define SR "REGULAR"

#define TYPE_PIZZA 0
#define TYPE_BEVRG 1

#define MAX_CAP 4

22
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

// Function Prototypes

void initialize( );
char *getTagName( int , int );
char *getSizeTag( int );
float getPrice( int , int );
float getSizeMod( int );
void displayMenu( int );

// global variables

float pizza_price[ 6 ];
float bevrg_price[ 3 ];

void initialize( )
{
// initialize pizza prize array

pizza_price[ 0 ] = 600.00f;
pizza_price[ 1 ] = 600.00f;
pizza_price[ 2 ] = 600.00f;
pizza_price[ 3 ] = 500.00f;
pizza_price[ 4 ] = 500.00f;
pizza_price[ 5 ] = 500.00f;

// initialize beverage price array

bevrg_price[ 0 ] = 150.00f;
bevrg_price[ 1 ] = 150.00f;
bevrg_price[ 2 ] = 200.00f;

char *getNameTag( int id, int type )


{

23
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

if( type == 0 )
{
switch( id )
{
case 0:
return HC;
case 1:
return DC;
case 2:
return SD;
case 3:
return SV;
case 4:
return CO;
case 5:
return IT;
}
}
else
if( type == 1 )
{
switch( id )
{
case 0:
return CC;
case 1:
return GB;
case 2:
return IC;
}
}
else
return NULL;

float getPrice( int id, int type )

24
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

{
if( type == 0 )
{
if( id > 5 || id < 0 )
{
return -1.00f;
}

return pizza_price[ id ];

}
else
if( type == 1 )
{
if( id > 2 || id < 0 )
{
return -1.00f;
}

return bevrg_price[ id ];
}
else
return -1.00f;
}

char *getSizeTag( int id )


{
switch( id )
{
case 0:
return SS;
case 1:
return SR;
case 2:
return SL;
}
}

25
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

float getSizeMod( int size )


{
switch( size )
{
case 0:
return PIZZA_SMALL;
case 1:
return PIZZA_REG;
case 2:
return PIZZA_LARGE;
}
}

void displayMenu( int type )


{
if( type == 0 )
{
printf( "\n\t\t%s\t%s\t\t%s", "ID", "Pizza Type", " Unit Price\n" );
for(int i=0;i<6;i++)
{
printf( "\n\t\t%d\t%s\t\t%.2f", i, getNameTag( i, type ), getPrice( i, type ) );
}
}
else
if( type == 1 )
{
printf( "\n\t\t%s\t%s\t\t%s", "ID", "Beverage Type", " Unit Price\n" );
for(int i=0;i<3;i++)
{
printf( "\n\t\t%d\t%s\t\t\t%.2f", i, getNameTag( i, type ),
getPrice( i, type ) );
}
}

26
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

Main C file

#include <billing.h>
#include <stdlib.h>
#include <conio.h>
#include <ctype.h>

// Arrays
int sizeArry[ 10 ];
int typeArry[ 10 ];
int selArry[ 10 ];
int qtyArry[ 10 ];

// Globals
float totalAmnt = 0.00f;
int noOfItems = 0;
int nextIndex = 0;

// Functions
void mainMenu( );
void orderMenu( );
void pizzaOrder( );
void bevrgOrder( );
void discardOrder( );
void viewOrder( );
void confirmOrder( );

int main( )
{
initialize( );
/*printf("%s",getNameTag(3,0));
printf("\t%.2f",getPrice(3,0));
printf("\n%s",getNameTag(1,1));
printf("\t%.2f",getPrice(1,1));*/

27
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

//displayMenu(0);
//printf("\n\n");
//displayMenu(1);

mainMenu( );
return 0;
}

void mainMenu( )
{
int choice = 0;

clrscr( );

printf( "\n\t--------------------------------------------------------------------" );
printf( "\n\t---------------------- WELCOME TO PIZZA HUT ----------------------" );
printf( "\n\t--------------------------------------------------------------------" );

printf( "\n\n\t\t\t\t 1.Place an Order " );


printf( "\n\n\t\t\t\t 2.Exit System \n" );
printf( "\n\t--------------------------------------------------------------------" );
printf( "\n\n\t Please Enter your choice: " );

fflush( stdin );
scanf( "%d", &choice );

switch( choice )
{
case 1:
if( noOfItems >= MAX_CAP )
{
printf( "\n\t\tMaximum Cap Reached...Press Any Key to
Continue" );
28
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

getch( );
mainMenu( );
}
else
orderMenu( );
break;
case 2:
exit( 0 );
break;
default:
printf( "\n\t\tInvalid Selection...Press Any Key to Continue" );
getch( );
mainMenu( );
break;
}

void orderMenu( )
{
int choice = 0;

clrscr( );

printf( "\n\t--------------------------------------------------------------------" );
printf( "\n\t---------------------- WELCOME TO PIZZA HUT ----------------------" );
printf( "\n\t--------------------------------------------------------------------" );
printf( "\n\n\t || ORDER MENU || \n" );

printf( "\n\n\t\t\t\t 1.Add Pizzas" );


printf( "\n\n\t\t\t\t 2.Add Beverages" );
printf( "\n\n\t\t\t\t 3.Discard Order" );

if( noOfItems > 0 )


29
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

{
printf( "\n\n\t\t\t\t 4.View Order" );
printf( "\n\n\t\t\t\t 5.Confirm Order" );
}

printf( "\n\n\t--------------------------------------------------------------------" );
printf( "\n\n\t Please Enter your choice: " );

fflush( stdin );
scanf( "%d", &choice );
fflush( stdin );

switch( choice )
{
case 1:
pizzaOrder( );
break;
case 2:
bevrgOrder( );
break;
case 3:
discardOrder( );
mainMenu( );
break;
case 4:
viewOrder( );
break;
case 5:
confirmOrder( );
break;
default:
printf( "\n\t\tInvalid Selection...Press Any Key to Continue" );
getch( );
orderMenu( );
30
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

break;
}

void pizzaOrder( )
{

if( noOfItems >= MAX_CAP )


{
printf( "\n\t\tMaximum Cap Reached...Press Any Key to Continue" );
getch( );
fflush( stdin );
orderMenu( );
return;
}

int type = -1;


int size = -1;
int qty = -1;
char confirm;

clrscr( );

printf( "\n\t--------------------------------------------------------------------" );
printf( "\n\t---------------------- WELCOME TO PIZZA HUT ----------------------" );
printf( "\n\t--------------------------------------------------------------------" );
printf( "\n\n\t || PIZZAS MENU || \n" );

displayMenu( TYPE_PIZZA );

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

printf( "\n\n\tEnter Pizza Type ID: " );


31
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

fflush( stdin );
scanf( "%d", &type );

printf( "\n\n\tEnter Size (0-Small | 1-Regular | 2-Large): " );


fflush( stdin );
scanf( "%d", &size );

printf( "\n\n\tEnter Quantity: " );


fflush( stdin );
scanf( "%d", &qty );

printf( "\n\n\tAdd more? (Y- Yes | N- No | D- Discard): " );


fflush( stdin );
scanf( "%c", &confirm );
confirm = toupper( confirm );

if( confirm == 'Y' || confirm == 'N' )


{
selArry[ nextIndex ] = type;
typeArry[ nextIndex ] = TYPE_PIZZA;
sizeArry[ nextIndex ] = size;
qtyArry[ nextIndex ] = qty;

noOfItems++;
nextIndex++;

if( confirm == 'Y' )


pizzaOrder( );
else
orderMenu( );
}
else
if( confirm == 'D' )
{
32
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

orderMenu( );
}
}

void bevrgOrder( )
{
if( noOfItems >= MAX_CAP )
{
printf( "\n\t\tMaximum Cap Reached...Press Any Key to Continue" );
getch( );
fflush( stdin );
orderMenu( );
return;
}

int type = -1;


int size = 3;
int qty = -1;
char confirm;

clrscr( );

printf( "\n\t--------------------------------------------------------------------" );
printf( "\n\t---------------------- WELCOME TO PIZZA HUT ----------------------" );
printf( "\n\t--------------------------------------------------------------------" );
printf( "\n\n\t || BEVERAGES MENU || \n" );

displayMenu( TYPE_BEVRG );

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

printf( "\n\n\tEnter Beverage Type ID: " );


fflush( stdin );
scanf( "%d", &type );
33
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

printf( "\n\n\tEnter Quantity: " );


fflush( stdin );
scanf( "%d", &qty );

printf( "\n\n\tAdd more? (Y- Yes | N- No | D- Discard): " );


fflush( stdin );
scanf( "%c", &confirm );
confirm = toupper( confirm );

if( confirm == 'Y' || confirm == 'N' )


{
selArry[ nextIndex ] = type;
typeArry[ nextIndex ] = TYPE_BEVRG;
sizeArry[ nextIndex ] = size;
qtyArry[ nextIndex ] = qty;

noOfItems++;
nextIndex++;

if( confirm == 'Y' )


bevrgOrder( );
else
orderMenu( );
}
else
if( confirm == 'D' )
{
orderMenu( );
}

void discardOrder( )
34
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

{
for(int i=0;i<MAX_CAP;i++)
{
selArry[ i ] = 0;
typeArry[ i ] = 0;
sizeArry[ i ] = 0;
qtyArry[ i ] = 0;
}

noOfItems = 0;
nextIndex = 0;

void viewOrder( )
{
clrscr( );

printf( "\n\t--------------------------------------------------------------------" );
printf( "\n\t---------------------- WELCOME TO PIZZA HUT ----------------------" );
printf( "\n\t--------------------------------------------------------------------" );
printf( "\n\n\t || VIEW ORDER || \n" );

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

printf( "\n\n\t%s\t%s\t%s\t%s\t%s", "Item Code", "Pizza Type", "Size", "Quantity",


"Sub Total" );
printf( "\n\t--------------------------------------------------------------------" );

for(int i=0;i<nextIndex;i++)
{
if( typeArry[ i ] == TYPE_PIZZA )
{
printf( "\n\t %d\t %s\t%s\t\ %d\t %.2f", selArry[ i ],
35
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

getNameTag( selArry[ i ], 0 ), getSizeTag( sizeArry[ i ]


), qtyArry[ i ],
getPrice( selArry[ i ], 0 ) * qtyArry[ i ] * getSizeMod(
sizeArry[ i ] ) );

/* totalAmnt=totalAmnt+(getPrice(selArry[i], */

/* 0)*qtyArry[i]*getSizeMod(sizeArry[i])
*/

/* );
*/
}
}

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

printf( "\n\n\t%s\t%s\t%s\t%s", "Item Code", "Beverage Type", " Quantity",


" Sub Total" );
printf( "\n\t--------------------------------------------------------------------" );

for(int j=0;j<nextIndex;j++)
{
if( typeArry[ j ] == TYPE_BEVRG )
{
printf( "\n\t %d\t %s\t\t%d\t\t%.2f", selArry[ j ],
getNameTag( selArry[ j ], 1 ), qtyArry[ j ],
getPrice( selArry[ j ], 1 ) * qtyArry[ j ] );

/* totalAmnt=totalAmnt+(getPrice(selArry[j], */

/* 1)*qtyArry[j]);
*/
}
36
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

printf( "\n\n\n\t\t\t....Press Any Key to Continue...." );


getch( );
fflush( stdin );
orderMenu( );
return;

void confirmOrder( )
{
char confirm;

clrscr( );

printf( "\n\t--------------------------------------------------------------------" );
printf( "\n\t---------------------- WELCOME TO PIZZA HUT ----------------------" );
printf( "\n\t--------------------------------------------------------------------" );
printf( "\n\n\t || VIEW ORDER || \n" );

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

printf( "\n\n\t%s\t%s\t%s\t%s\t%s", "Item Code", "Pizza Type", "Size", "Quantity",


"Sub Total" );
printf( "\n\t--------------------------------------------------------------------" );

for(int i=0;i<nextIndex;i++)
{
if( typeArry[ i ] == TYPE_PIZZA )
{
printf( "\n\t %d\t %s\t%s\t\ %d\t %.2f", selArry[ i ],
37
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

getNameTag( selArry[ i ], 0 ), getSizeTag( sizeArry[ i ]


), qtyArry[ i ],
getPrice( selArry[ i ], 0 ) * qtyArry[ i ] * getSizeMod(
sizeArry[ i ] ) );
totalAmnt
= totalAmnt
+ ( getPrice( selArry[ i ], 0 ) * qtyArry[ i ] * getSizeMod( sizeArry[ i
] ) );
}
}

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

printf( "\n\n\t%s\t%s\t%s\t%s", "Item Code", "Beverage Type", " Quantity",


" Sub Total" );
printf( "\n\t--------------------------------------------------------------------" );

for(int j=0;j<nextIndex;j++)
{
if( typeArry[ j ] == TYPE_BEVRG )
{
printf( "\n\t %d\t %s\t\t%d\t\t%.2f", selArry[ j ],
getNameTag( selArry[ j ], 1 ), qtyArry[ j ],
getPrice( selArry[ j ], 1 ) * qtyArry[ j ] );
totalAmnt = totalAmnt + ( getPrice( selArry[ j ], 1 ) * qtyArry[ j ] );
}
}

printf( "\n\n\t--------------------------------------------------------------------" );
printf( "\n\tPay by Mastercard/Visa ? : " );
fflush( stdin );
scanf( "%c", &confirm );
confirm = toupper( confirm );

38
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

if( confirm == 'Y' )


{
if( totalAmnt > 2500.00f )
{
printf( "\n\t 10% Discount Applied" );
printf( "\n\t Grand TOTAL: %.2f", totalAmnt - ( totalAmnt *
DISCOUNT ) );
}
else
printf( "\n\t Grand TOTAL: %.2f", totalAmnt );
}
else
if( confirm == 'N' )
{
printf( "\n\t Grand TOTAL: %.2f", totalAmnt );
}

discardOrder( );
totalAmnt = 0.00f;

printf( "\n\n\n\t\t\t....Press Any Key to Continue...." );


getch( );
fflush( stdin );
mainMenu( );
return;

39
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

Work Breakdown Structure

Agreed Work Percentage

Name Percentage Work Signature

Ashan Dhanapala 60%

Sahan Madusanka 40%

I, hereby agree that the all of the assignment works were done by me.

Name of Group Leader: Ashan Dhanapala

Group Leader’s Signature: ____________________

40
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design Using C

References

Deitel H.M, P.J Deitel. (2002). C How to program. In: Deitel H.M C How to program. USA:
Deitel. p1-p477.

41
Asia Pacific Institute of Information Technology

También podría gustarte