
| Turbo C - Cash Register Program |
|
#include<stdio.h> #include<stdio.h> /* Programmed by Harvey Losin */ /* http://www.bikoy.com/harvey */ /* webmaster@bikoy.com */ int qty0, qty1, qty2, qty3, qty4, qty5; char value[4][20]; float sub0, sub1, sub2, sub3, sub4, sub5, payment, total; float price(float sub0, float sub1, float sub2, float sub3, float sub4); float change(float payment, float total); main() { int x,y,z; char ch, menu[3][30]= {" CUSTOMER DATA ENTRY ", " CASHIER ", " EXIT ",}; { textattr(15); x=0; y=0; menu: clrscr(); gotoxy(27,8); printf("============================="); gotoxy(35,9); printf("Pick-an-Entry"); gotoxy(27,10); printf("============================="); for(z=0;z<3;z++) /* PRINTS ALL CONTENTS OF MENU ARRAY */ { gotoxy(27,11+z); printf("%s", menu[z]); } gotoxy(27,19); /* PRINTS THE menu[0] AS FIRST DESCRIPTION */ textattr(14); cprintf("%s", menu[y]); } do { textattr(15); gotoxy(27,11+y); textbackground(10); /* SETS THE BACKGROUND OF THE HIGHLIGHT */ cprintf("%s", menu[y]); ch=toupper(getch()); textattr(15); /* RESETS ALL TEXT ATTRIBUTES TO WHITE AFTER ASKING */ switch(ch) { case 80: if(y<2) { x=-1; y++; } else { x=1; y=0; goto menu; } break; case 72: if(y>0) { x=1; y--; } else { x=-1; y=2; goto menu; } break; } gotoxy(27,19); textattr(14); cprintf("%s", menu[y]); textattr(15); gotoxy(27,11+y+x); cprintf("%s", menu[x+y]); }while(ch!=13); switch(y) { case 0: customer(); case 1: cashier(); case 2: out(); } } customer() { int w, x=0, y=0, pass_try=3; char ch, pass[10]; char customer[5][22]= {"Name of Customer :", "Address of Customer :", "Date of Transaction :", "Time of Transaction :", "[<] BACK ",}; repeat: clrscr(); textattr(2); gotoxy(30,5); cprintf("CUSTOMER DATA ENTRY"); textattr(13); if(pass_try==0) { gotoxy(21,15); cprintf("You have reached the maximum attempts..."); gotoxy(29,16); cprintf("Program terminating..."); getch(); exit(); } gotoxy(30,8); cprintf("Enter password: "); fflush(stdin); gets(pass); if(!strcmp(pass,"cash")) { clrscr(); repeat2: textattr(2); gotoxy(30,5); cprintf("CUSTOMER DATA ENTRY"); textattr(14); for(w=0; w<5; w++) { gotoxy(20,8+w); cprintf("%s",customer[w]); } do { textattr(14); gotoxy(20,8+y); textbackground(10); cprintf("%s", customer[y]); ch=toupper(getch()); textattr(14); switch(ch) { case 80: if(y<3) { x=-1; y++; } else { x=1; y=0; goto repeat2; } break; case 72: if(y>0) { x=1; y--; } else { x=-1; y=3; goto repeat2; } break; case 75: main(); } textattr(14); gotoxy(20,8+y+x); cprintf("%s", customer[x+y]); }while(ch!=13); if(y==0) { gotoxy(42,8); textattr(15); scanf("%s",&value[0]); gotoxy(42,8); textattr(15); cprintf(" %s ",value[0]); goto repeat2; } if(y==1) { gotoxy(42,9); textattr(15); scanf("%s",&value[1]); gotoxy(42,9); cprintf(" %s ",value[1]); goto repeat2; } if(y==2) { gotoxy(42,10); textattr(15); scanf("%s",&value[2]); gotoxy(42,10); cprintf(" %s ",value[2]); goto repeat2; } if(y==3) { gotoxy(42,11); textattr(15); scanf("%s",&value[3]); gotoxy(42,11); cprintf(" %s ",value[3]); goto repeat2; } goto repeat2; } else { gotoxy(22,13); cprintf("Invalid password! Please try again..."); pass_try=pass_try--; getch(); goto repeat; } } cashier() { |