Suppose you have to develop a program for managing the sales of your grocery store. The following functions have been requested by your Head (The shopkeeper):
1: The program should allow the user to select and buy different items present in that shop.
2: The user should be able to see the items that he has bought and print his total bill on the screen
3: The program should not end until the user specifies it to end. (The user should press 'q' to quit the program)
how can i print the total and how can the man (who came for shopping) buy other items too.in the above program the buyer cannot buy more than one thing why?Code:#include <stdio.h> #include <stdlib.h> #include <conio.h> int main(){ char choice; int x,sugar=350,jam=250,shampoo=199,bread=50 ,eggs=90,subtotal1=0,subtotal2=0,subtotal3=0,subtotal4=0,subtotal5=0,total; printf("WELCOME TO NUST DHABBA\n"); printf("World's biggest Departmental store\n"); printf("Enter choice\n"); printf("[1] for 1 kg sugar bag\n"); printf("[2] for Jam\n"); printf("[3] for XYZ Shampoo\n"); printf("[4] for Bread\n"); printf("[5] for 1 dozen eggs\n"); printf("[q] to quit shoping\n"); choice=getch(); if((choice=='q')||(choice=='Q')) exit(0); if(choice=='1') { printf("shopped:1 kg sugar bag=350 rupees\n",sugar); printf("how many?\n",x); scanf("%d",&x); subtotal1=sugar*x; printf("Sub total:sugar=%d",subtotal1); getche(); } if(choice=='2'){ printf("Shopped:Jam=250\n",jam); printf("How many?\n",x); scanf("%d",&x); subtotal2=jam*x; printf("Sub total:Jam=%d",subtotal2); getch(); } if(choice=='3') { printf("shopped:XYZ shampoo\n",shampoo); printf("How many?\n",x); scanf("%d",&x); subtotal3=shampoo*x; printf("Sub total:shampoo=%d",subtotal3); getch(); } if(choice=='4'){ printf("Shopped:Bread\n",bread); printf("How many?\n",x); scanf("%d",&x); subtotal4=bread*x; printf("Sub total:Bread=%d",subtotal4); getch(); } if(choice=='5') { printf("shopped:dozen eggs\n",shampoo); printf("How many dozens you want?\n",x); scanf("%d",&x); subtotal5=eggs*x; printf("Sub total:eggs=%d",subtotal5); getch(); }}



LinkBack URL
About LinkBacks



