here's some code that i made. It is a simple Video Rental System. Can you please tell your suggestions, or help me in enhancing this code.
It is a module program that can add customers, edit, search or delete customers.
CODE
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define size 100
main()
{
int IDnum[size];
int age[size];
char gender[size];
int quantity[size];
float amount[size];
float totalAmount[size];
int ID;
int ctr=0;
int ctr2=0;
int edit;
char choice;
char over;
int add;
int delete;
int search;
int not = 0;
textmode(C40);
textbackground(LIGHTBLUE);
main: clrscr();
textcolor(BLINK+LIGHTGREEN);
gotoxy(5,3);
cprintf("ß ß ß VIDEO RENTAL SYSTEM ß ß ß");
gotoxy(17,6);
textcolor(YELLOW);
cprintf("[A]-Add");
gotoxy(17,8);
cprintf("[S]-Search");
gotoxy(17,10);
cprintf("[E]-Edit");
gotoxy(17,12);
cprintf("[D]-Delete");
gotoxy(17,14);
cprintf("[Q]-Quit");
gotoxy(3,18);
cprintf("Enter choice: ");
choice=getche();
switch(choice)
{
case 'a':
case 'A':
clrscr();
do{
gotoxy(3,12);
cprintf("How many customers?: ");
scanf("%d",&add);
}while(add<0);
ctr2=0;
while(ctr2<add)
{
clrscr();
gotoxy(3,5);
ID: cprintf("\nEnter ID number: ");
scanf("%d",&ID);
if(ID == IDnum[ctr2])
{
clrscr();
goto ID;
}
IDnum[ctr] = ID;
do{
gotoxy(3,7);
cprintf("Enter Gender: ");
gender[ctr]=getche();
}while(gender[ctr] !='m' && gender[ctr] !='M' && gender[ctr] != 'f' && gender[ctr] !='F');
do{
gotoxy(3,9);
cprintf("Enter Age: ");
scanf("%d",&age[ctr]);
}while(age[ctr] <= 0);
gotoxy(3,11);
do{
cprintf("How many rented items?: ");
scanf("%d",&quantity[ctr]);
gotoxy(3,13);
}while(quantity[ctr] < 0);
cprintf("How much each?: ");
scanf("%f",&amount[ctr]);
totalAmount[ctr]=quantity[ctr]*amount[ctr];
gotoxy(3,15);
cprintf("The total amount is: %f",totalAmount[ctr]);
ctr++;
ctr2++;
}while(ctr2<add);
textcolor(LIGHTGREEN+BLINK);
gotoxy(3,17);
cprintf("File added to memory...");
gotoxy(5,20);
system("pause");
break;
case 's':
case 'S':
clrscr();
not = 1;
gotoxy(3,12);
cprintf("What ID you want to search?: ");
scanf("%d",&search);
clrscr();
for(ctr2=0;ctr2<size;ctr2++)
{
if( search == IDnum[ctr2])
{
gotoxy(5,4);
textcolor(LIGHTGREEN+BLINK);
cprintf("ß ß ß Customers information ß ß ß");
gotoxy(5,7);
printf("ID number: %d",IDnum[ctr2]);
gotoxy(5,9);
printf("Gender: %c",gender[ctr2]);
gotoxy(5,11);
printf("Age: %d",age[ctr2]);
gotoxy(5,13);
printf("Items rented: %d",quantity[ctr2]);
gotoxy(5,15);
printf("Rent amount: %f",amount[ctr2]);
gotoxy(5,17);
printf("Total amount: %f",totalAmount[ctr2]);
gotoxy(5,20);
system("pause");
goto main;
}
}
if ( not == 0 );
{
textcolor(RED+BLINK);
gotoxy(3,12);
cprintf("File not found!");
gotoxy(5,16);
system("pause");
}
break;
case 'e':
case 'E':
clrscr();
gotoxy(1,12);
cprintf("\nEnter ID number you want to edit: ");
scanf("%d",&edit);
clrscr();
for(ctr2=0;ctr2<size;ctr2++)
{
if(edit==IDnum[ctr2])
{
gotoxy(3,5);
cprintf("Enter new ID number: ");
scanf("%d",&IDnum[ctr2]);
do{
gotoxy(3,7);
cprintf("Enter Gender: ");
gender[ctr2]=getche();
}while(gender[ctr2] != 'm' && gender[ctr2] != 'M' && gender[ctr2] != 'f' && gender[ctr2] != 'F');
gotoxy(3,9);
do{
cprintf("Enter Age: ");
scanf("%d",&age[ctr2]);
gotoxy(3,11);
}while(age[ctr] <= 0);
do{
cprintf("How many rented items?: ");
scanf("%d",&quantity[ctr2]);
}while(quantity[ctr2] < 0);
gotoxy(3,13);
do{
cprintf("How much each?: ");
scanf("%f",&amount[ctr2]);
}while(amount[ctr2] < 0);
totalAmount[ctr2]=quantity[ctr2]*amount[ctr2];
gotoxy(3,16);
cprintf("The total amount is: %f",totalAmount[ctr2]);
textcolor(LIGHTGREEN+BLINK);
gotoxy(5,20);
cprintf("File succesfully updated!");
gotoxy(5,22);
system("pause");
goto main;
}
}
if (not == 0);
{
textcolor(BLINK+RED);
gotoxy(3,12);
cprintf("File not found!");
gotoxy(5,16);
system("pause");
goto main;
}
case 'd':
case 'D':
clrscr();
gotoxy(3,12);
cprintf("What file you want to delete: ");
scanf("%d",&delete);
clrscr();
for(ctr2=0;ctr2<size;ctr2++)
{
if ( delete == IDnum[ctr2])
{
IDnum[ctr2]='0';
gender[ctr2]='0';
age[ctr2]='0';
quantity[ctr2]='0';
amount[ctr2]='0';
totalAmount[ctr2]='0';
textcolor(LIGHTGREEN+BLINK);
gotoxy(5,10);
cprintf("File Deleted!");
gotoxy(5,12);
system("pause");
goto main;
}
}
if (not == 0);
{
textcolor(RED+BLINK);
gotoxy(3,12);
cprintf("File not found!");
gotoxy(5,16);
system("pause");
goto main;
}
case 'q':
case'Q':
exit(0);
default:
cprintf("\a");
clrscr();
break;
}
goto main;
}