Professional Documents
Culture Documents
Asia Pacific Institute of Information Technology: Assignment Title
Asia Pacific Institute of Information Technology: Assignment Title
Asia Pacific Institute of Information Technology: Assignment Title
Using C
Assignment Title
Group Assignment
Intake Code
DF0971ICT
Submitted By
Submitted To
Date Assigned
Date Due
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
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.
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.
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
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,
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
5
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design
Using C
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.
6
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.
To place orders.
To exit.
Add pizzas.
Add beverages.
View order.
Confirm order.
Discard order.
7
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design
Using C
View 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,
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.
8
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design
Using C
Flowcharts
void mainMenu( ); - To display main menu
9
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design
Using C
void orderMenu( ); - To display 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.
12
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design
Using C
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.
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.
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
Pizza Menu
Beverages Menu
16
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.
17
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.
18
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design
Using C
Limitations
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.
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.
We used Borland compiler to compile our code. Sometimes it gave errors which we
could not understand to debug.
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.
19
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design
Using C
Further Development
A hardcopy of the bill can be printed to handover to the customer as receipt of the
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.
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.
20
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.
21
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design
Using C
Appendices
Gantt Chart
22
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design
Using C
Source Code
Billing.h
#include <stdio.h>
// Definistions
#define SIZE_SMALL 0
#define SIZE_REG 1
#define SIZE_LARGE 2
#define SIZE_NONE 3
#define SS "SMALL"
#define SL "LARGE"
#define SR "REGULAR"
#define TYPE_PIZZA 0
#define TYPE_BEVRG 1
23
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design
Using C
#define MAX_CAP 4
// 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;
bevrg_price[ 0 ] = 150.00f;
bevrg_price[ 1 ] = 150.00f;
bevrg_price[ 2 ] = 200.00f;
24
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;
25
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design
Using C
float getPrice( int id, int type )
{
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;
}
26
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design
Using C
}
27
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design
Using C
28
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));*/
29
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--------------------------------------------------------------------" );
fflush( stdin );
scanf( "%d", &choice );
switch( choice )
{
case 1:
if( noOfItems >= MAX_CAP )
{
printf( "\n\t\tMaximum Cap Reached...Press Any Key to
Continue" );
30
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--------------------------------------------------------------------" );
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( );
32
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design
Using C
break;
}
void pizzaOrder( )
{
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--------------------------------------------------------------------" );
noOfItems++;
nextIndex++;
void bevrgOrder( )
{
if( noOfItems >= MAX_CAP )
{
printf( "\n\t\tMaximum Cap Reached...Press Any Key to Continue" );
getch( );
fflush( stdin );
orderMenu( );
return;
}
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--------------------------------------------------------------------" );
noOfItems++;
nextIndex++;
void discardOrder( )
36
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--------------------------------------------------------------------" );
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--------------------------------------------------------------------" );
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]);
*/
}
38
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design
Using C
}
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--------------------------------------------------------------------" );
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 ],
39
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--------------------------------------------------------------------" );
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 );
40
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;
41
Asia Pacific Institute of Information Technology
DF0971ICT Problem Solving And Program Design
Using C
I, hereby agree that the all of the assignment works were done by me.
42
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.
43
Asia Pacific Institute of Information Technology