#include <stdio.h>
#include <string.h>
#include <conio.h>
#include<stdlib.h>
int fstock1, fstock2, fstock3;
int opt1, opt2, cCost, length, gTotal;
int stock1= 5;
int stock2= 10;
int stock3= 15;
//---------------------------------------------------------------------------------------------
void welcome()
{
system ("cls");
printf ("\n ||||''|| . ...\n");
printf (" |||| ||| |||''|| '||| |||. .|| ||| .||''||.\n");
printf (" |||| |||' ''' ||| |||' .||| .||||||| .' ||| '''''\n");
printf (" ||||'''|| ....||| ||| ||| '||.....\n");
printf (" |||| '||| ||| ||| ||| ||| ..... '||.\n");
printf (" |||| .|| |||| ||| : ||| ||| : '|| .||'\n");
printf (" ''''''''' ''''''''' ''''' ''' '''''''\n");
printf ("\n\t\t\t\t\t\tCAR RENTAL COMPANY\n");
printf ("\n\t\t\t (Administrators ONLY)");
printf("\n\n\n\n\n\t\t\tPress any key to proceed.");
getch();
}
/**********************************************************************************************/
/**********************************************************************************************/
/**********************************************************************************************/
/**********************************************************************************************/
void Rents()
{
int opt2, opt4;
system("cls");
printf ("\n\n\n1. First Class\n2. Second Class\n3. Third Class\n0. Exit");
printf ("\nPlease enter the class desired to be RENTED: ");
scanf ("%d", &opt2);
while (opt2!= 1&& opt2!= 2&& opt2!= 3&& opt2!= 0)
{
printf ("Invalid option. Try again.");
getch();
Rents();
}
switch (opt2)
{
case 1: if (stock1< 1)
{
printf ("We are sorry but there are no more cars of this class.");
printf ("\n\n1. Retry\n2. Main Menu\nPlease select an option: ");
scanf ("%d", &opt4);
while (opt4!= 1 &&opt4!= 2)
{
printf("\nInvalid option. Please try again: ");
opt4=NULL;
scanf ("%d", &opt4);
}
}
else
{
stock1= stock1--;
cCost= 2000.00;
printf ("\n\nThis class of car costs: $%d.\n", cCost);
printf ("\nHow long is the length of rent (in days)? ");
scanf ("%d", &length);
gTotal= length*cCost;
printf ("\n\nThe gross total cost is $%d", gTotal);
printf ("\nThe remaining stock of First Class cars are: %d", stock1);
printf ("\n\nPress any key to proceed. ");
getch ();
system ("cls");
}
break;
case 2: if (stock2< 1)
{
printf ("We are sorry but there are no more cars of this class.");
}
else
{
stock2= stock2--;
cCost= 1500.00;
printf ("\n\nThis class of car costs: $%d\n", cCost);
printf ("\nHow long is the length of RENT (in days)? ");
scanf ("%d", &length);
gTotal= length*cCost;
printf ("\n\nThe gross total cost is $%d", gTotal);
printf ("\nThe remaining stock of Second Class cars are: %d", stock2);
printf ("\n\nPress any key to proceed.");
getch ();
system ("cls");
}
break;
case 3: if (stock3< 1)
{
printf ("We are sorry but there are no more cars of this class.");
}
else
{
stock3= stock3--;
cCost= 1000.00;
printf ("\n\nThis class of car costs: $%d\n", cCost);
printf ("\nHow long is the length of rent (in days)? ");
scanf ("%d", &length);
gTotal= length*cCost;
printf ("\n\nThe gross total cost is $%d", gTotal);
printf ("\nThe remaining stock of Third Class cars are: %d", stock3);
printf ("\n\nPress any key to proceed.");
getch();
system ("cls");
}
break;
default: ("\nInvalid option");
}
}
/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&& This is the Returns Function &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
********************************************************************************************
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
void Returns()
{
int opt5;
system("cls");
printf ("\n\n\n1. First Class\n2. Second Class\n3. Third Class\n0. Exit");
printf ("\nPlease enter the class desired to be RETURNED: ");
scanf ("%d", &opt5);
while (opt5!=1 &&opt5!=2 &&opt5!= 3 &&opt5!= 0)
{
printf ("Invalid option. Please try again.");
getch();
Returns ();
}
switch (opt5)
{
case 0: main();
break;
case 1: if (stock1>= 5)
{
printf ("The stocks for this type of car is full.");
printf ("\n\n\tPress any key to try again");
getch();
Returns();
}
else
{
stock1= stock1++;
printf ("\nThe remaining stock First Class cars are: %d", stock1);
printf ("\n\n\tPress any key to proceed. (Client Records Section)");
getch ();
system ("cls");
}
break;
case 2: if (stock2>= 10)
{
printf ("The stocks for this type of car is full.");
printf ("\n\n\tPress any key to try again.");
getch();
Returns();
}
else
{
stock2>= stock2++;
printf ("\nThe remaining stock Second Class cars are: %d", stock2);
printf ("\n\nPress any key to proceed. (Client Records Section)");
getch ();
system ("cls");
}
break;
case 3: if (stock3>= 15)
{
printf ("The stocks for this type of car is full.");
printf ("\n\n\tPress any key to try again.");
getch();
Returns();
}
else
{
stock3= stock3++;
printf ("\nThe remaining stock Third Class cars are: %d", stock3);
printf ("\n\nPress any key to proceed. (Client Records Section)");
getch ();
system ("cls");
}
break;
default: ("\nInvalid option");
getch ();
}
}
//--------------------------------------------------------------------------------------------
void Info()
{
FILE *Clients;
char fname[30], sname[30], email[40], trans[6];
int tfone;
if((Clients=fopen("ClientInfo.txt","r"))==NULL)
{
printf ("The Clients Record was not found, press any button to create one.\n");
getch();
system("cls");
Clients=fopen("ClientInfo.txt","a+");
}
else
{
Clients=fopen("ClientInfo.txt","a");
}
system ("cls");
printf ("Enter client's First name: ");
scanf ("%s",&fname);
printf ("\nEnter client's Surname: ");
scanf ("%s",&sname);
printf ("\nEnter client's E-mail address: ");
scanf ("%s",&email);
printf ("\nEnter client's contact number: ");
scanf ("%s",&tfone);
printf ("\nDid the client RENT or RETURN a car(s)\n");
scanf ("%s",&trans);
fprintf (Clients,"\nTransaction done: %s",&trans);
fprintf (Clients,"\nName of Client: %s",&fname);
fprintf (Clients,"%s",&sname);
fprintf (Clients,"\nE-mail Address: %s",&email);
fprintf (Clients,"\nContact Number: %d",&tfone);
fprintf (Clients,"\n\n\n");
fclose (Clients);
printf ("\nSaved!\nPress any button to proceed");
getch();
system("cls");
}
//----------------------------------------------------------------------------------------------
void Stock()
{
FILE *Stocks;
int stock1, stock2, stock3;
system ("cls");
printf ("Press any key to continue. (Stock Section)");
getch();
if((Stocks=fopen("Stocks.txt","r"))==NULL)
{
printf("The Stock Document was not found, Press any button to create one.\n");
getch();
system("cls");
Stocks=fopen("Stocks.txt","a+");
}
else
{
Stocks=fopen("Stocks.txt","a");
}
printf ("\nThe amount of First Class cars Stocks remaining are: %d", &stock1);
printf ("\nThe amount of Second Class cars Stocks remaining are: %d", &stock2);
printf ("\nThe amount of Third Class cars Stocks remaining are: %d", &stock3);
fprintf (Stocks,"\nThe amount of First Class Stocks remaining are: %d\n", &stock1);
fprintf (Stocks,"The amount of Second Class Stocks remaining are: %d\n", &stock2);
fprintf (Stocks,"The amount of Third Class Stocks remaining are: %d\n", &stock3);
fclose (Stocks);
printf("Saved!\n\nPress any button to return to menu");
getch();
system("cls");
main();
}
/****************************************************************************************************************/
/****************************************************************************************************************/
/****************************************************************************************************************/
int Transactions()
{
int opt3;
printf ("1. Yes\t2. No");
printf ("Are there any further transactions to be done? ");
scanf ("%d", &opt3);
while (opt3!= 1&& opt3!= 2)
{
printf ("Invalid option. Try again");
getch ();
Transactions();
}
if (opt3=1)
{
main();
}
else if (opt3=2)
{
printf ("\n\n\t\t\tPlease have a nice day.\n\n\t\tPress any key to exit.");
getch();
}
else
{
printf ("That is an invalid option.");
}
return 0;
}
//--------------------------------------------------------------------------------------------
void Final()
{
printf ("\n\n .|||||||||||||.\n");
printf (" .|||||||||||||||||||||.\n");
printf (" .|||||||'|||||||||||'|||||||.\n");
printf (" .||||||||' '|||||||||' '||||||||.\n");
printf (" .||||||||| ||||||||| |||||||||.\n");
printf (" .|||||||||| ||||||||| ||||||||||.\n");
printf (" .||||||||||| ||||||||| |||||||||||.\n");
printf (" .||||||||||| ||||||||| |||||||||||.\n");
printf (" :|||||^|||||. .|||||||||. .||||||^||||:\n");
printf (" '||||| ||||||.|||||||||||.||||||| ||||'\n");
printf (" '||||| |||||||||||||||||||||||||| ||||'\n");
printf (" '|||||. .||||'\n");
printf (" '|||||. .|||||'\n");
printf (" '||||. .||||'\n");
printf (" '|||||. .|||||'\n");
printf (" '||||||||||||||||||||'\n");
printf (" '||||||||||||||'\n");
printf ("\n\n\t\tHave a nice day!");
}
//--------------------------------------------------------------------------------------------
int main ()
{
int opt1;
welcome();
void mainmenu()
{
int opt1;
system ("cls");
printf ("1. Rent\n2. Return\n0. Exit\n\n");
printf ("Please select the desired option: ");
scanf ("%d", &opt1);
while (opt1!= 1&& opt1!= 2&& opt1!= 0)
{
printf ("\nThat is not an option. Try again.\n ");
getch ();
mainmenu();
}
if (opt1== 1)
{
Rents();
Info();
Stock();
Transactions();
}
else if (opt1== 2)
{
Returns();
Info();
Stock();
Transactions();
}
else if (opt1== 0)
{
Final();
printf ("\n\n\t\tPlease have a nice day.\n\n\t\tPress any key to exit.");
getch();
}
}
mainmenu();
//--------------------------------------------------------------------------------------------
return 0;
}
mattboy64 13 Newbie Poster
mattboy64 13 Newbie Poster
mattboy64 13 Newbie Poster
tux4life 2,072 Postaholic
mattboy64 13 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.