C Programming

August 1, 2017 | Author: Ahamed Nishadh | Category: Credit Card, Payments, Invoice, Computer Programming, Computing
Share Embed Donate


Short Description

C Programming Assignment for 1st Year 1st Semester of APIIT...

Description

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

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

th

Submission Date :

25 January 2011

Students Names

Leader :

Due Date :

25th January 2011

A.N.Ahamed Nishadh (CB004081)

and ID :

Members : S.D.Ilangakoon (CB004041) A.C.Tiffaniya Fernando (CB004165)

49 pages

Total Number of Pages :

i

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

ii

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

iii

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

iv

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.

1

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,

2

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. 3

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.

4

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

5

4.0 – SOURCE CODE #include #include #include #include #include #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() 6

{ 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 (mainmenu0); }

//"NEW ORDER" FUNCTION STARTS HERE void neworder() { int filling; cancelor=0; do { clrscr(); 7

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(ccountcrem) { 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; 16

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"); 17

return; } case 2:{ cancelor=1; return; } default:{ printf("\n INVALID CHOICE!!!\n PRESS ANY KEY TO CONTINUE"); getch(); } } }while(confirm>0 || confirm1000) { bill[count].discount=(bill[count].subtotal*0.1); 18

bill[count].total=bill[count].subtotalbill[count].discount; } else if(bill[count].subtotal0||pay
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF