Upload
ahamed-nishadh
View
728
Download
6
Embed Size (px)
DESCRIPTION
C Programming Assignment for 1st Year 1st Semester of APIIT
Citation preview
ASIA PACIFIC INSTITUTE OF INFORMATION
TECHNOLOGY
APIIT Diploma Part II
INCOURSE ASSIGNMENT
Problem Solving and Program Design Using C
Prepared By
A.N.Ahamed Nishadh (CB004081)
S.D.Ilangakoon (CB004041)
A.C.Tiffaniya Fernando (CB004165)
Module Code & Title
AAPP005-3-2 – PSPD
Cohort
DF10A1ICT
Date of Submission
25th January 2011
Instructor
Mr.Thangavel Saravanan
Submitted in partial fulfillment for the degree of
Bachelor of Science (Hons) in Computing
i
STUDENT DECLARATION:
I Declare that:
We understand what is meant by plagiarism.
The implications of plagiarism have been explained to us by our lecturer.
This project is all our work and I have acknowledged any use of the
published or unpublished works of other people.
Group Leader’s Signature : Date :
25th
January 2011
Total number of pages : 49 pages Class Code : DF10A1ICT
Submission Date : 25th
January 2011 Due Date : 25th
January 2011
Students Names
and ID :
Leader :
A.N.Ahamed Nishadh (CB004081)
Members :
S.D.Ilangakoon (CB004041)
A.C.Tiffaniya Fernando (CB004165)
Total Number of Pages : 49 pages
ii
ACKNOWLEDGEMENTS
Firstly we would like to thank our lecturer Mr.Thangavel Saravanan for all the
help and guidance given to us while doing this assignment. Especially for
teaching us this module in such a way that we were able to learn this highly
technical module very easily.
Also there are many individuals who have helped us in numerous ways directly
and indirectly so that we were able to complete this assignment.
APIIT Lanka for providing us with resources and the Tech Team at APIIT Lanka
for their assistance at required times.
And last but not least our friends, parents and the well-wishers without whose
moral support and encouragement, we would not have been able to do a good job.
Finally, if there are any shortcomings in this project, then we request to excuse us
for all those and accept this documentation.
Ahamed Nishadh
Deshan Ilangakoon
Tiffaniya Fernando
iii
TABLE OF CONTENTS
1.0 - INTRODUCTION ............................................................................................... 1
1.1 – OBJECTIVES ............................................................................................. 1
1.2 – KEY SUCCESS CRITERIA ...................................................................... 1
1.3 – CONSTRAINTS ......................................................................................... 1
2.0 – PROJECT DESCRIPTION ................................................................................. 2
3.0 – PSEUDO CODE .................................................................................................. 5
4.0 – SOURCE CODE ................................................................................................. 6
5.0 – PROGRAMMING CONCEPTS APPLIED ...................................................... 22
5.1 – IF, ELSE Conditions ................................................................................. 22
5.2 – LOOPS (WHILE AND DO-WHILE) ...................................................... 22
5.3 – SWITCH COMMANDS .......................................................................... 23
5.4 – STRUCTURES ......................................................................................... 24
5.4.1 – DEFINING A STRUCTURE ............................................................. 24
5.4.2 – DECLARING STRUCTURE VARIABLE ....................................... 24
5.4.3 – USING STRUCTURE VARIABLES ................................................ 24
5.5 – FUNCTIONS ............................................................................................ 24
5.5.1 – DEFINING FUNCTIONS ................................................................. 24
5.5.2 – DECLARING FUNCTIONS ............................................................. 25
5.5.3 – CALLING FUNCTIONS ................................................................... 26
6.0 – USER GUIDE ................................................................................................... 27
iv
6.1 – MAIN MENU ........................................................................................... 27
6.2 – NEW ORDER ........................................................................................... 28
6.2.1 – NEW ORDER: BREAD TYPE ......................................................... 29
6.2.2 – NEW ORDER: SANDWICH SIZE ................................................... 30
6.2.3 – NEW ORDER: TOPPING ................................................................. 30
6.2.4 – NEW ORDER: NO. OF SANDWICHES REQUIRED ..................... 32
6.2.5 – NEW ORDER: CONFIRM ORDER ................................................. 34
6.2.6 – NEW ORDER: PAYMENT METHOD ............................................ 34
6.2.7 – NEW ORDER: FINAL BILL – CASH PAYMENT ......................... 35
6.2.8 – NEW ORDER: FINAL BILL – CREDIT CARD PAYMENT ......... 36
6.2.9 – INVALID ENTRY ............................................................................. 36
6.3 – CHECK AVAILABLE SANDWICHES .................................................. 37
6.4 - EXIT .......................................................................................................... 39
7.0 – LIMITATIONS AND FUTURE ENHANCEMENTS ..................................... 40
7.1 – LIMITATIONS ......................................................................................... 40
7.2 – FURTHER ENHANCEMENTS .............................................................. 40
8.0 – CONCLUSION ................................................................................................. 41
9.0 – BIBLIOGRAPHY ............................................................................................. 42
10.0 – AGREED WORK PERCENTAGE ................................................................. 43
1
1.0 - INTRODUCTION
This program is a Point of Sale System for a Sandwich Bar. This system will be
only used by the shop’s assistant who will enter the order as the customer
provides the requirements. The system will take the order; do all necessary
calculations and printing the receipts. The guide lines that we will use when doing
the development of the project will be according to the objectives, given below
that we hope to achieve by the end of the development.
1.1 – OBJECTIVES
Make a faster and more reliable point of sale system for the Sandwich Bar.
Generate accurate and up to date reports for management on the
performance of the shop.
Maintain all transaction details and store this information in a separate file.
Make the system easy and simple for the user to operate.
1.2 – KEY SUCCESS CRITERIA
The project should be completed with the allocated time frame for it.
The project should meet all the above mentioned objectives.
Should not be a burden, on the company, to operate.
1.3 – CONSTRAINTS
In the case where the project encounters problems and Code needs to be
changed the company will need someone with professional knowledge in
C Programing language for assistance.
The system will need a C compiler to operate and this software does not
come pre-installed in most computers.
2
2.0 – PROJECT DESCRIPTION
The system that we have developed is for a sandwich bar that we have called
“DAT Sandwich Bar”. The system operational flow is fairly straight forward and
easy to follow. For the effective running of this system we have used several
functions, switches, while loops and structures. The system uses all these features
to help in running smoothly.
The system starts off by showing the main menu. At this point the system requires
an input from the user as to whether he wishes to make a New Order, Check
Available Sandwiches or whether he wishes to quit. To do this the user will have
to enter 1, 2 or 3 depending on the choice of action respectively. Here we have
used a Switch that will read the information that is entered and will them
according to the information that is given the Switch will call a function to carry
out the operation that the user has selected.
If the user selects 1 the system will then take the user to the New Order section of
the system. Here the user is presented with 4 choices. The first three relate to
which type of filling that the customer wishes to have. The fourth is to cancel the
order and go back to the main menu.
In the event that the user wishes to make a new order he will have to simply enter
1, 2 or 3 for the three types of sandwiches which are Chicken, Seafood and
Vegetarian respectively and the system will store the information and move in to
the “breadf” function.
Here the system goes into the “breadf” Function where the user will have to enter
what sort of bread the customer wishes to have. The three options are 1-Baguette,
2-Foccacia and 3-Ciabatta.
From here the system will move to the next segment of the new Order process
where the customer has to enter the size of the sandwich he wishes to eat. This is
done in the “sizef” Function. The user has to select from three sizes Large,
3
Medium and Small. The system will then take the user to the next process which
is the “topf” Function.
Here the user must enter the toping that he wishes to have on the sandwich. He is
provided with three options 1-Cheese, 2-Meyoneese and 3-Special Sauce. The
user can have either one, two or all three of the toppings. He can also opt not to
have any of the available toppings. This process works by having a While loop
and a Do While loop that will run three times asking the user to enter a topping or
until the user opts to exit the topping option by selecting ‘0’ that will jump the
system out of the loop.
After the user has given the specifications for his sandwich the user will then be
asked how many sandwiches he wishes to have of the particular type that he has
selected. For this the function “qytf” will be called up. Here when the user enters
the choice the system will run a check to see if there is sufficient filling to satisfy
the customer’s requirement. If there is not the system will prompt an error saying
that there is insufficient filling to meet the order requirement for that particular
type of filling. Here the user will have to re-enter a quantity that meets the
available amount present in the system. If there is sufficient amount of filling to
meet the customer’s order then the system moves on to the next function is the the
“invoice” Function.
Here the user is presented with a screen showing his order and will request the
user to select whether the order displayed is in fact correct. If it is not the user
must enter ‘n’ and the system will then return back to the main menu and the user
can start the process again. If the order is correct the user will have to enter ‘y’
and the system will take the user to the next stage of the process.
When the user has confirmed that the order is in fact what was requested then the
system will ask the user what the method of payment will be. Here there are two
options available for the user.
One the user can select to make the payment by Cash. If the user selects this
option then the system will simply display the final bill for the user.
4
If however the user selects to make a payment by credit card then the system will
again move to the final bill process but here if the user has made an order that is
greater than Rs. 1,000/= he is eligible to receive a discount of 10% if the credit
card type is Visa Credit Card. Here we have made the assumption that the
Sandwich Bar will only accept Visa Credit Card.
Once this is done the system will show the bill containing the individual price per
sandwich, the relevant discount that takes into effect and the Grand Total.
After this the user can return to the main menu to either make a new order or to
select one the two remaining options.
The next option that the user is presented with when the system is at the main
menu is the option to check how many more sandwiches can be made. This runs
through the “availability” Function. If the user selects this option the system will
move into the next segment where the system prompts the user to enter the type of
bread that the user wishes to search for. When the user does this the system will
display how many more sandwiches of the particular bread type can be made.
After this the system will move back to the main menu.
The user if he has finished all the work that he has to do with the system may opt
to shut the system down. To do this the user simply has to go to the main menu
and select the Exit option. This will then shut the program down.
5
3.0 – PSEUDO CODE
START
BEGIN
READ option
IF (option == neworder)
READ filling
IF (filling == available)
READ bread
READ size
READ topping
READ quantity
READ confirmorder
IF (confirmorder = yes)
subtotal = (((bread and filling price) + (price of toppings)) x
(price of size)) x (quantity)
READ Payment Method
IF (payment method == cash)
total=subtotal
END IF
IF (payment method = credit card AND subtotal >1000)
discount=(subtotal x 0.1)
total=subtotal-discount
ELSE
total=subtotal
END IF
ELSE
DISPLAY “Order Cancelled”
END IF
END IF
IF (option == availability)
remainder = (maximum quantity) – (filling counter)
DISPLAY remainder
END IF
IF (option == exit)
CLOSE PROGRAM
END IF
END
6
4.0 – SOURCE CODE
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include <time.h>
#define max 5
//DEFINING STRUCTURES
struct order {
char bread;
char filling;
char size;
int topping[3];
int tqty;
float subtotal;
float discount;
char payment;
float total;
};
//GLOBAL VARIABLES
int count=0;
int ccount=0;
int scount=0;
int vcount=0;
int chk=0;
int filltemp;
int cancelor=0;
//STRUCTURE VARIABLES
struct order bill[15];
//DECLARING FUNCTIONS
void neworder();
void breadf();
void sizef();
void topf();
void qtyf();
void invoice();
void paymentf();
void billf();
void availability();
//MAIN PROGRAM STARTS HERE
void main()
7
{
int mainmenu;
do
{
clrscr();
printf("\n D.A.T. SANDWICH BAR\n
===================\n\n");
printf(" MAIN MENU\n ---------\n\n\n");
printf(" WHAT DO YOU WANT TO DO :\n 1. New Order\n 2.
Check Available Sandwiches\n\n 3. Exit\n\n\n Choice is : ");
flushall();
scanf("%d",&mainmenu);
switch(mainmenu)
{
case 1:
{
neworder();
break;
}
case 2:
{
availability();
break;
}
case 3:
{
_exit(0);
break;
}
default:
{
printf("\n INVALID CHOICE!!!\n PRESS
ANY KEY TO CONTINUE");
}
}
getch();
}while (mainmenu<=3||mainmenu>0);
}
//"NEW ORDER" FUNCTION STARTS HERE
void neworder()
{
int filling;
cancelor=0;
do
{
clrscr();
8
printf("\n D.A.T. SANDWICH BAR\n
===================\n\n");
printf(" NEW ORDER\n ---------\n\n");
printf(" Enter the Type of Filling Required\n 1.Chicken\n
2.Seafood\n 3.Vegetarian\n\n 4.CANCEL ORDER\n\n Choice is : ");
flushall();
scanf("%d",&filling);
switch(filling)
{
case 1:
{
if(ccount<max)
{
bill[count].filling='C';
if(cancelor==0)
{
breadf();
}
if(cancelor==0)
{
sizef();
}
if(cancelor==0)
{
topf();
}
if(cancelor==0)
{
qtyf();
}
if(cancelor==0)
{
invoice();
}
return;
}
else
{
printf("CHICKEN SANDWICHES
SOLD OUT!!!");
printf("\nPRESS 'ENTER' TO RE-
ENTER CHOICE");
getch();
break;
}
}
case 2:
{
if(scount<max)
9
{
bill[count].filling='S';
if(cancelor==0)
{
breadf();
}
if(cancelor==0)
{
sizef();
}
if(cancelor==0)
{
topf();
}
if(cancelor==0)
{
qtyf();
}
if(cancelor==0)
{
invoice();
}
return;
}
else
{
printf("SEAFOOD SANDWICHES
SOLD OUT!!!");
printf("\nPRESS 'ENTER' TO RE-
ENTER CHOICE");
getch();
break;
}
}
case 3:
{
if(vcount<max)
{
bill[count].filling='V';
if(cancelor==0)
{
breadf();
}
if(cancelor==0)
{
sizef();
}
if(cancelor==0)
{
topf();
10
}
if(cancelor==0)
{
qtyf();
}
if(cancelor==0)
{
invoice();
}
return;
}
else
{
printf("VEGETARIAN
SANDWICHES SOLD OUT!!!");
printf("\nPRESS 'ENTER' TO RE-
ENTER CHOICE");
getch();
break;
}
}
case 4:
{
cancelor=1;
printf("\nORDER CANCELLED!!! PRESS
'ENTER' TO GO TO MAIN MENU");
getch();
return;
}
default:
{
printf("\n INVALID CHOICE!!!\n PRESS
ANY KEY TO CONTINUE");
getch();
}
}
}while (filling>0||filling<=4);
}
//"BREAD TYPE" FUNCTION STARTS HERE
void breadf()
{
int bread;
do
{
clrscr();
printf("\n D.A.T. SANDWICH BAR\n
===================\n\n");
11
printf(" NEW ORDER\n ---------\n\n");
printf("YOUR CURRENT ORDER\n------------------\n");
printf("Filling : %c\n",bill[count].filling);
printf("\n\n Enter the Type of Bread Required\n 1.Baguette\n
2.Foccacia\n 3.Ciabatta\n\n 4.CANCEL ORDER\n\n Choice is : ");
flushall();
scanf("%d",&bread);
switch(bread)
{
case 1:
{
bill[count].bread='B';
if(bill[count].filling=='C')
{
bill[count].subtotal=200;
}
if(bill[count].filling=='S')
{
bill[count].subtotal=300;
}
if(bill[count].filling=='V')
{
bill[count].subtotal=100;
}
return;
}
case 2:
{
bill[count].bread='F';
if(bill[count].filling=='C')
{
bill[count].subtotal=250;
}
if(bill[count].filling=='S')
{
bill[count].subtotal=350;
}
if(bill[count].filling=='V')
{
bill[count].subtotal=150;
}
return;
}
case 3:
{
bill[count].bread='C';
if(bill[count].filling=='C')
{
bill[count].subtotal=225;
12
}
if(bill[count].filling=='S')
{
bill[count].subtotal=325;
}
if(bill[count].filling=='V')
{
bill[count].subtotal=125;
}
return;
}
case 4:
{
cancelor=1;
printf("\nORDER CANCELLED!!! PRESS
'ENTER' TO GO TO MAIN MENU");
getch();
return;
}
default:
{
printf("\n INVALID CHOICE!!!\n PRESS
ANY KEY TO CONTINUE");
getch();
}
}
}while (bread<=4||bread>0);
}
//"SIZE" FUNCTION STARTS HERE
void sizef()
{
int size;
do
{
clrscr();
printf("\n D.A.T. SANDWICH BAR\n
===================\n\n");
printf(" NEW ORDER\n ---------\n\n");
printf("YOUR CURRENT ORDER\n------------------\n");
printf("Filling : %c\n",bill[count].filling);
printf("Bread : %c\n",bill[count].bread);
printf("\n\n Enter the Size of the Sandwitch Required\n 1.Large\n
2.Medium\n 3.Small\n\n 4.CANCEL ORDER\n\n Choice is : ");
flushall();
scanf("%d",&size);
switch(size)
13
{
case 1:
{
bill[count].size='L';
bill[count].subtotal=(bill[count].subtotal+(bill[count].subtotal*0.2));
return;
}
case 2:
{
bill[count].size='M';
bill[count].subtotal=(bill[count].subtotal+(bill[count].subtotal*0.1));
return;
}
case 3:
{
bill[count].size='S';
bill[count].subtotal=bill[count].subtotal;
return;
}
case 4:
{
cancelor=1;
printf("\nORDER CANCELLED!!! PRESS
'ENTER' TO GO TO MAIN MENU");
getch();
return;
}
default:
{
printf("\n INVALID CHOICE!!!\n PRESS
ANY KEY TO CONTINUE");
getch();
}
}
}while (size<=4||size>0);
}
//"TOPPING SELECT" FUNCTION STARTS HERE
void topf()
{
int top,temp=0;
bill[count].topping[0]=0;
bill[count].topping[1]=0;
bill[count].topping[2]=0;
do
{
14
clrscr();
printf("\n D.A.T. SANDWICH BAR\n
===================\n\n");
printf(" NEW ORDER\n ---------\n\n\n");
printf("YOUR CURRENT ORDER\n------------------\n");
printf("Filling : %c\n",bill[count].filling);
printf("Bread : %c\n",bill[count].bread);
printf("Size : %c\n",bill[count].size);
do
{
printf("\n\n Enter the Toppings Required\n 1.Cheese (Rs.
50)\n 2.Mayonnaise (Rs.25)\n 3.Special Sauce (Rs.100)\n 0.To STOP
Entering\n\n 4.CANCEL ORDER\n\n Choice is : ");
flushall();
scanf("%d",&top);
if(top!=0)
{
bill[count].topping[temp]=top;
if(top==1)
{
bill[count].subtotal=bill[count].subtotal+50;
temp++;
}
if(top==2)
{
bill[count].subtotal=bill[count].subtotal+25;
temp++;
}
if(top==3)
{
bill[count].subtotal=bill[count].subtotal+100;
temp++;
}
if(top==4)
{
cancelor=1;
printf("\nORDER CANCELLED!!! PRESS
'ENTER' TO GO TO MAIN MENU");
getch();
return;
}
if(top>4)
{
printf("\n INVALID CHOICE!!!\n PRESS
ANY KEY TO CONTINUE");
getch();
}
}
else
15
{
return;
}
if(temp==3)
{
return;
}
}while(temp<3 && top!=0);
}while (top!=0);
}
//"QUANTITY" FUNCTION STARTS HERE
void qtyf()
{
int qty;
int crem=max-ccount;
int srem=max-scount;
int vrem=max-vcount;
int qtyc=0;
do
{
clrscr();
printf("\n D.A.T. SANDWICH BAR\n
===================\n\n");
printf(" NEW ORDER\n ---------\n\n\n");
printf("YOUR CURRENT ORDER\n------------------\n");
printf("Filling : %c\n",bill[count].filling);
printf("Bread : %c\n",bill[count].bread);
printf("Size : %c\n",bill[count].size);
printf("Sub Total : %.2f",bill[count].subtotal);
printf("\n\n HOW MANY SANDWICHES DO YOU WANT\n\n
Choice is : ");
flushall();
scanf("%d",&qty);
switch(bill[count].filling)
{
case 'C':
{
if(qty>crem)
{
printf("REQUESTED AMOUNT
NOT AVAILABLE\n");
printf("ONLY %d SANDWICHES
AVAILABLE",crem);
qtyc=1;
printf("\nEnter Quantity Again");
getch();
16
break;
}
else
{
bill[count].tqty=qty;
qtyc=0;
bill[count].subtotal=(bill[count].subtotal*bill[count].tqty);
return;
}
}
case 'S':
{
if(qty>srem)
{
printf("REQUESTED AMOUNT
NOT AVAILABLE\n");
printf("ONLY %d SANDWICHES
AVAILABLE",srem);
printf("\nEnter Quantity Again");
qtyc=1;
getch();
break;
}
else
{
bill[count].tqty=qty;
qtyc=0;
bill[count].subtotal=(bill[count].subtotal*bill[count].tqty);
return;
}
}
case 'V':
{
if(qty>crem)
{
printf("REQUESTED AMOUNT
NOT AVAILABLE\n");
printf("ONLY %d SANDWICHES
AVAILABLE",srem);
qtyc=1;
printf("\nEnter Quantity Again");
getch();
break;
}
else
{
bill[count].tqty=qty;
qtyc=0;
17
bill[count].subtotal=(bill[count].subtotal*bill[count].tqty);
return;
}
}
}
}while (qtyc==1);
}
//"INVOICE" FUNCTION STARTS HERE
void invoice()
{
int confirm;
do
{
clrscr();
printf("\n D.A.T. SANDWICH BAR\n
===================\n\n");
printf(" NEW ORDER\n ---------\n\n\n");
printf(" YOUR CURRENT ORDER\n ------------------\n");
printf(" Filling : %c\n",bill[count].filling);
printf(" Bread : %c\n",bill[count].bread);
printf(" Size : %c\n",bill[count].size);
printf(" Sub Total : Rs.%.2f\n",bill[count].subtotal);
printf(" Total Number of Sandwitches Required :
%d\n",bill[count].tqty);
printf("\n\n CONFIRM ORDER (1:Yes/2:No) : ");
flushall();
scanf("%d",&confirm);
switch(confirm)
{
case 1:{
paymentf();
billf();
if(bill[count].filling=='C')
{
ccount=ccount+bill[count].tqty;
}
if(bill[count].filling=='S')
{
scount=ccount+bill[count].tqty;
}
if(bill[count].filling=='V')
{
vcount=ccount+bill[count].tqty;
}
count++;
printf("Press 'ENTER' to Close the Bill");
18
return;
}
case 2:{
cancelor=1;
return;
}
default:{
printf("\n INVALID CHOICE!!!\n PRESS ANY
KEY TO CONTINUE");
getch();
}
}
}while(confirm>0 || confirm<=2);
}
//"PAYMENT" FUNCTION STARTS HERE
void paymentf()
{
int pay;
do
{
clrscr();
printf("\n D.A.T. SANDWICH BAR\n
===================\n\n");
printf(" NEW ORDER\n ---------\n\n\n");
printf(" YOUR CURRENT ORDER\n ------------------\n");
printf(" Sub Total : Rs.%.2f\n",bill[count].subtotal);
printf(" Total Number of Sandwitches Required :
%d\n",bill[count].tqty);
printf("\n\n\n 1.Cash\n 2.Credit Card\n Payment Method : ");
flushall();
scanf("%d",&pay);
switch(pay)
{
case 1:{
bill[count].discount=0;
bill[count].total=bill[count].subtotal;
bill[count].payment='C';
return;
}
case 2:{
if(bill[count].subtotal>1000)
{
bill[count].discount=(bill[count].subtotal*0.1);
19
bill[count].total=bill[count].subtotal-
bill[count].discount;
}
else if(bill[count].subtotal<1000)
{
bill[count].discount=0;
bill[count].total=bill[count].subtotal;
}
bill[count].payment='V';
return;
}
default:{
printf("\n INVALID CHOICE!!!\n PRESS ANY
KEY TO CONTINUE");
getch();
}
}
}while(pay>0||pay<=2);
}
//"BILL PRINTING" FUNCTION STARTS HERE
void billf()
{
clrscr();
printf("\n D.A.T. SANDWICH BAR\n
===================\n\n");
printf(" NEW ORDER\n ---------\n\n\n");
printf(" YOUR ORDER\n ------------------\n");
printf(" Filling : %c\n",bill[count].filling);
printf(" Bread : %c\n",bill[count].bread);
printf(" Size : %c\n",bill[count].size);
printf(" Toppings : %d %d
%d\n",bill[count].topping[0],bill[count].topping[1],bill[count].topping[2]);
printf(" Total Number of Sandwitches Required :
%d\n",bill[count].tqty);
printf(" Sub Total : Rs.%.2f\n",bill[count].subtotal);
printf(" Discount : Rs.%.2f\n",bill[count].discount);
printf(" Payment Method : %c\n",bill[count].payment);
printf("\n TOTAL : Rs.%.2f\n \n\n",bill[count].total);
}
//*AVAILABILITY" FUNCTION STARTS HERE
void availability()
{
clrscr();
int fill;
int crem=max-ccount;
20
int srem=max-scount;
int vrem=max-vcount;
do
{
printf("\n D.A.T. SANDWICH BAR\n
===================\n\n");
printf(" AVAILABLIE SANDWICHES\n\n\n");
printf(" Enter the Type of Filling \n 1.Chicken\n 2.Seafood\n
3.Vegetarian\n\n 4.CANCEL \n\n Choice is : ");
flushall();
scanf("%d",&fill);
switch(fill)
{
case 1:
{
printf("\n\nAvailable Chicken Sandwiches
are : %d",crem);
printf("\n\nPRESS 'ENTER' TO GO
BACK");
getch();
return;
}
case 2:
{
printf("\n\nAvailable Seafood Sandwiches
are : %d",srem);
printf("\n\nPRESS 'ENTER' TO GO
BACK");
getch();
return;
}
case 3:
{
printf("\n\nAvailable Vegetarian
Sandwiches are : %d",vrem);
printf("\n\nPRESS 'ENTER' TO GO
BACK");
getch();
return;
}
case 4:
{
return;
}
default:
{
printf("\n INVALID CHOICE!!!\n PRESS
ANY KEY TO CONTINUE");
getch();
21
}
}
}while (fill>0||fill<=4);
}
22
5.0 – PROGRAMMING CONCEPTS APPLIED
This system uses various programing concepts. Below is a list of the
programming concepts that we have used along with examples of codes from our
system itself.
5.1 – IF, ELSE Conditions
if(qty>crem)
{
printf("REQUESTED AMOUNT NOT AVAILABLE\n");
printf("ONLY %d SANDWICHES AVAILABLE",crem);
qtyc=1;
printf("\nEnter Quantity Again");
getch();
break;
}
else
{
bill[count].tqty=qty;
qtyc=0;
bill[count].total=(bill[count].subtotal*bill[count].tqty);
return;
}
5.2 – LOOPS (WHILE AND DO-WHILE)
do
{
printf("\n\n Enter the Toppings Required\n 1.Cheese (Rs. 50)\n
2.Mayonnaise (Rs.25)\n 3.Special Sauce (Rs.100)\n 0.To STOP
Entering\n\n 4.CANCEL ORDER\n\n Choice is : ");
flushall();
scanf("%d",&top);
if(top!=0)
{
bill[count].topping[temp]=top;
if(top==1)
{
bill[count].subtotal=bill[count].subtotal+50;
}
if(top==2)
{
bill[count].subtotal=bill[count].subtotal+25;
}
if(top==3)
23
{
bill[count].subtotal=bill[count].subtotal+100;
}
if(top==4)
{
cancelor=1;
printf("\nORDER CANCELLED!!! PRESS 'ENTER'
TO GO TO MAIN MENU");
getch();
return;
}
}
else
{
return;
}
if(temp==3)
{
return;
}
temp++;
}while(temp<3 && top!=0);
5.3 – SWITCH COMMANDS
switch(mainmenu)
{
case 1:
{
neworder();
break;
}
case 2:
{
availability();
break;
}
case 3:
{
_exit(0);
break;
}
default:
{
printf("\n INVALID CHOICE!!!\n PRESS ANY KEY
TO CONTINUE");
}
}
24
5.4 – STRUCTURES
5.4.1 – DEFINING A STRUCTURE
struct order {
char bread;
char filling;
char size;
int topping[3];
int tqty;
float subtotal;
float discount;
char payment;
float total;
};
5.4.2 – DECLARING STRUCTURE VARIABLE
struct order bill[15];
5.4.3 – USING STRUCTURE VARIABLES
printf(" YOUR ORDER\n ------------------\n");
printf(" Filling : %c\n",bill[count].filling);
printf(" Bread : %c\n",bill[count].bread);
printf(" Size : %c\n",bill[count].size);
printf(" Toppings : %d %d %d\n", bill[count].topping[0],
bill[count].topping[1], bill[count].topping[2]);
printf(" Total Number of Sandwitches Required : %d\n",bill[count].tqty);
printf(" Sub Total : Rs.%.2f\n",bill[count].subtotal);
printf(" Discount : Rs.%.2f\n",bill[count].discount);
printf(" Payment Method : %c\n",bill[count].payment);
printf("\n TOTAL : Rs.%.2f\n \n\n",bill[count].total);
5.5 – FUNCTIONS
5.5.1 – DEFINING FUNCTIONS
void availability();
25
5.5.2 – DECLARING FUNCTIONS
void availability()
{
clrscr();
int fill;
int crem=max-ccount;
int srem=max-scount;
int vrem=max-vcount;
do
{
printf("\n D.A.T. SANDWICH BAR\n
===================\n\n");
printf(" NEW ORDER\n ---------\n\n\n");
printf(" YOUR ORDER\n ------------------\n");
printf(" Enter the Type of Filling \n 1.Chicken\n
2.Seafood\n 3.Vegetarian\n\n 4.CANCEL \n\n Choice is :
");
flushall();
scanf("%d",&fill);
switch(fill)
{
case 1:
{
printf("\n\nAvailable Chicken Sandwiches
are : %d",crem);
printf("\n\nPRESS 'ENTER' TO GO
BACK");
getch();
return;
}
case 2:
{
printf("\n\nAvailable Seafood Sandwiches
are : %d",srem);
printf("\n\nPRESS 'ENTER' TO GO
BACK");
getch();
return;
}
case 3:
{
printf("\n\nAvailable Vegetarian
Sandwiches are : %d",vrem);
printf("\n\nPRESS 'ENTER' TO GO
BACK");
getch();
return;
}
26
case 4:
{
return;
}
default:
{
printf("\n INVALID CHOICE!!!\n PRESS
ANY KEY TO CONTINUE");
getch();
}
}
}while (fill>0||fill<=4);
}
5.5.3 – CALLING FUNCTIONS
case 2:
{
availability();
break;
}
27
6.0 – USER GUIDE
Given below are the instructions for the user of this system to help acquire the
maximum out of this system. The user guide is a tool in helping the user work
more efficiently with the system and also to prevent any errors.
To open the system go the location where the system has been saved and select
the “Application” file, in this case named as “Main 2”. For the initial opening of
this system a warming saying “Open File – Security Warning” may appear. In this
case simply select “Run” option.
6.1 – MAIN MENU
When this is done the system will open on to the main menu of the system. The
window that you will see is given bellow:
Figure 1: Main Menu
Here the three choices are available for selection depending on the function that
the user wishes to carry out:
28
6.2 – NEW ORDER
When the system opens in the Main Menu it waits till the user gives an input
depending on the task that he or she wishes to carry out. To make a New Order
the user must press ‘1’ and press ‘Enter’. When this is done the window in the
image below will appear:
Figure 2: New Order - Filling
At this point the user will have to get the customers filling requirement, i.e. the
type of sandwich he requires. There are three options available for the user to
select from. These are “Chicken”, “Seafood” and “Vegetarian”. The user can
select any of the above options depending on the customer’s requirement by
pressing either ‘1’, ‘2’or ‘3’ for “Chicken”, “Seafood” and “Vegetarian”
respectively. If the user does not wish to continue any further but wishes to return
to the Main Menu all he has to do is select ‘4’ and press enter when the system
prompts it and the user is returned to the main menu as shown in the image below:
29
Figure 3: Cancel Order
6.2.1 – NEW ORDER: BREAD TYPE
No matter which type of filling the customer wishes the system will move on to
the next option where the user will enter the preferred bread type of the customer.
For this the window shown in the image below will appear:
Figure 4: New Order - Bread Type
Here the user is presented with another three choices to select from; ‘1’ for
“Baguette”, ‘2’ for “Foccacia” and ‘3’ for “Ciabatta”. The user is also shown the
type of filling that he has selected under the current order section. Once the type
of bread that the customer wants has been selected the user must enter the relevant
30
number and press ‘Enter’. When this is done the system will move on to the next
window.
6.2.2 – NEW ORDER: SANDWICH SIZE
When the user has entered the type of bread that the customer wishes and presses
‘Enter’ the system goes to a new window that is shown below where the size of
the sandwich has to be selected.
Figure 5: New Order - Size
The user will enter either ‘1’, ‘2’ or three depending on whether the customer
wants a size ‘Large’ or size ‘Medium’ or size ‘Small’ respectively. Once the user
has entered the customer required size of the sandwich he can press enter and
move to the next window or he can choose to cancel the order by pressing 4 and
entering it.
6.2.3 – NEW ORDER: TOPPING
Once the size of the sandwich that the customer wishes is entered, the system
moves to the next stage where the system asks for the toppings that the customer
wants. The customer is presented again with three choices 1-Cheese, 2-
Meyoneese and 3-Special Sauce. The customer at this point can either pick one,
31
two or all three toppings. If he at any point wants to end choosing a topping all he
has to do is to enter ‘0’ and the system jump to the next window. Given below is
how the system will display the options available to the user.
Figure 6: New Order - Topping 1
Figure 7: New Order - Topping 2
32
Figure 8: New Order - Topping 3
After each of the selection the user is given the choice to stop selecting a topping
or the user can simply not have any topping at all.
6.2.4 – NEW ORDER: NO. OF SANDWICHES REQUIRED
Once the user has entered the topping that the customer wants he is presented with
a choice of how many sandwiches, fitting the specifications that he has selected
earlier, the customer wants. At this point the user will enter the number of
sandwiches the customer wants.
33
Figure 9: New Order - Quantity
Here the system will check if there is sufficient filling to meet that demand. If
there is not the following will be displayed and the user will have to enter a new
amount depending on what is available:
Figure 10: New Order - Request Unavailable
If there is sufficient filling to meet the customer’s requirements then the system
will move on to the next window.
34
6.2.5 – NEW ORDER: CONFIRM ORDER
Once the customer has completed all of the requirements above the system will
prompt the user to confirm the customer’s order. In this window the customer is
shown a rough outline of what he has ordered and the total of the order. Here the
user must enter either ‘1’ for Yes or ‘2’ for No. If the customer selects no the
system will return to the main menu and the user can re-start the process. If the
customer selects Yes the system will move on to the next window. Given below is
a screen shot of the choice whether the order is correct or not:
Figure 11: New Order - Confirm Order
6.2.6 – NEW ORDER: PAYMENT METHOD
The next stage is to select the payment method that the customer wants. There are
two options available for the customer; 1-Cash or 2-Credit Card. An image of the
screen the user will see is given below:
35
Figure 12: New Order - Payment Method
After this the system will move to the next window. Here depending on whether
the customer selected Cash or Credit Card the final Grand Total will vary as a
discount will be taken into consideration.
6.2.7 – NEW ORDER: FINAL BILL – CASH PAYMENT
If the customer wishes to make the payment by Cash the screen will not display
any discount but will simply show the following screen.
Figure 13: New Order - Cash Payment Bill
36
6.2.8 – NEW ORDER: FINAL BILL – CREDIT CARD
PAYMENT
If however the customer wishes to make the payment via a Credit Card and the
sub total of the bill is greater than Rs. 1,000/= then the customer is given a
discount of 10% and the screen in the image below is shown:
Figure 14: New Order - Credit Payment Bill
After this the system will return to the Main Menu.
6.2.9 – INVALID ENTRY
In all of the places where the user is expected to enter a values the user may
inadvertently enter an incorrect input. In this case an error message of the given
nature will appear and the user will be prompted to enter a correct input. In a
situation the error massage that will appear in any part of the process is given
below:
37
Figure 15: Invalid Entry
At this point to recover all the user has to do is to press any key as instructed and
the system will take the user back to the point where an input is required.
6.3 – CHECK AVAILABLE SANDWICHES
The main menu also has an option to search for how many sandwiches of a
particular filling type are available. This is because there is only a limited number
of filling of each type.
To access this window to see the number of remaining sandwiches the user must
press ‘2’ to go to the “Check Available Sandwiches” option as shown below:
38
Figure 16: Check Availability
After this the system enters to a new window where the user is prompted to enter
the type of filling of which the availability is being searched. This can be seen in
the image below:
Figure 17: Check Availability Example
Here once you enter the type of filling the system will show how many fillings of
that particular type is available. After this the user must press enter to return to the
Main Menu.
39
6.4 - EXIT
The final option is Exit. If the user selects this option the system will close down.
This is to be done once the user has finished working with the system. If he
wishes to restart the program the user should follow the instructions given at the
beginning of the User Guide.
40
7.0 – LIMITATIONS AND FUTURE ENHANCEMENTS
7.1 – LIMITATIONS
The system has a few limitations that we, during the course of the development
tried and failed to accomplish. They are given bellow:
The system has only a simple and basic user interface that is the default
interface that appears when running the Compiler.
As this system is built using C programming language the recipient of the
system will be unable to make any changes to the system without having a
thorough knowledge in the programming language.
The system at current runs on the assumption that the sandwich bar has a
limited supply of filling (enough for five sandwiches of each type). In the
event this changes the user will have to make alteration in the coding and
the above problem will be encountered.
Also, only one type of sandwich (type of filling, bread, size and toppings
should be same for all sandwiches in one order) can be selected per order.
7.2 – FURTHER ENHANCEMENTS
During the development of the project we attempted to accomplish but were
unable to do so as we did not know how to handle it or was considered to be out
of scope. These areas we hope to work on in the future in order to make the
system provide even greater benefits. They are as follows:
Save records to a file
Create reports
Read information from saved files
41
8.0 – CONCLUSION
The project has been completed successfully within the time frame that was
allocated for the system. The project kept with the given specifications that we
mentioned in the scope of the project.
The team managed to function together with great efficiency where each would
cover the others weaknesses and thus helping the whole team to excel and a single
unit. We have been able to greatly benefit from the strengths that the other team
members processed and thus helping us individually also to excel in the subject.
We have been given a chance through this project to ally the theoretical
knowledge that we obtained during the class sessions and apply them in a
practical sense by doing this assignment.
42
9.0 – BIBLIOGRAPHY
Dietel, PJ & HM 2008, How To Programme C, 5th edn, Hall of India (Pvt) Ltd,
New Delhi.
Saravanan, T 2010, 'Problem Solving and Program Design Using C', LECTURES,
School of Computing, Asia Pacific Institute of Information Technology, Asia
Pacific Institute of Information Technology, Colombo.
43
10.0 – AGREED WORK PERCENTAGE
TASK AHAMED DESHAN TIFFANIYA
Introduction 100% 0% 0%
Project Description 0% 30% 70%
Program Design 60% 20% 20%
C Programming Concepts 60% 20% 20%
User Guide 10% 70% 20%
Limitation and Future
Enhancements
50% 50% 0%
Conclusion 33.34% 33.34% 33.34%
Reference 0% 0% 0%
System Implementation 33.34% 33.34% 33.34%
SIGNATURE
TOTAL OF 100% 40% 35% 25%
I, hereby agree that the above members have undertaken the above tasks and their
work is reflective of what I have written above.
Group Leader : A.N.Ahamed Nishadh (CB004081)
Signature :