You are required to write a program for a Used Car Dealer company. In the system you need
to maintain the cars’ inventory and details. Each car in the company contains the following
details:
• Car Registration Number
• Car Make or Brand
• Car Model
• Car Colour (eg. Silver, Black , Red)
• Year of manufacturing (The year the car was manufacture)
• Engine Capacity (in cc)
• Transmission (manual or automatic)
• Cost of the car (RM)
The Car Registration Number is in the format of AAA1234 or AA1234A or A1234A which is
accordance to the Malaysia car registration format. The A alphabet is in accordance to the
registration number for respective in Malaysia. (eg. AEW9829 or W1212Y or MCD1177).
Note the A and the 1234 total count in the registration number can be less than 3 like AT9829
or BHY280.
The Car Make is for the identifying the manufacturer of the car like Honda, Toyota,
Proton..etc.
The Car Model is to represent the Manufacturers’ respective model like Honda City, Honda Civic, Honda Accord, Toyota Vios, Toyota Camry … etc.
You are required to create menu and operations for:
1) Create a new Car account
2) Edit existing Car account details
3) Remove a car account from the system
4) Search for cars in the system (based on Car Make, Model, Year of manufacturing or Price)
5) Check total inventory in the system
**propose two additional
operations that can be performed by the system.
int main()
{
string Car[50][8];
string Car_reg_num;
string Car_manuf;
string Car_model;
string Car_color;
string Year_of_manuf;
string Engin_capacity;
string Transmission;
string Cost_of_car;
int Num_car_system = 0;
int iSelection;
bool flag=true;
while(flag==true)
{
cout<<endl;
cout<< " 1 : Create a new car account "<<endl;
cout<< " 2 : Edit existing car account details "<<endl;
cout<< " 3 : Remove a car account from the system "<<endl;
cout<< " 4 : Search for cars in the system "<<endl;
cout<< " (based on Car Brand, Model, Year of manufacturing or Price) "<<endl;
cout<< " 5 : Check total inventory in the system "<<endl<<endl;
cout<< " Please Select Your Choice : ";
cin>>iSelection;
if(iSelection == 1)
{
New_car_account(Num_car_system, Car);
}
else if(iSelection == 2)
{
if(Num_car_system!=0)
Edit_existing_car_account(Num_car_system, Car);
else
cout<<"You have no record in the system."<<endl;
}
else if(iSelection == 3)
{ if(Num_car_system!=0)
Remove_existing_car_account(Num_car_system, Car);
else
cout<<"You have no record in the system."<<endl;
}
else if(iSelection == 4)
{
if(Num_car_system!=0)
Search_existing_car_account(Num_car_system, Car);
else
cout<<"You have no record in the system."<<endl;
}
else if(iSelection == 5)
{
if(Num_car_system!=0)
Search_all_inv(Num_car_system, Car);
else
cout<<"You have no record in the system."<<endl;
}
else
{
cout<< " Please Enter Selection 1 - 5 "<<endl;
}
}
system("pause");
return 0;
}
void New_car_account(int &Num_car_system, string Car[][8])
{
bool running;
cout<< " Please enter car registration number : ";
cin>>Car[Num_car_system][0];
cout<< " Please enter car brand : ";
cin>>Car[Num_car_system][1];
cout<< " Please enter car model : ";
cin>>Car[Num_car_system][2];
cout<< " Please enter car color : ";
cin>>Car[Num_car_system][3];
cout<< " Please enter year of manufacturing : ";
cin>>Car[Num_car_system][4];
cout<< " Please enter the car's engine capacity(cc) : ";
cin>>Car[Num_car_system][5];
cout<< " Please enter the type of transmission "<<endl;;
cout<< " 1 for Auto 2 for Manual : ";
cin>>Car[Num_car_system][6];
while(true)
{
running = false;
cout<< " Please enter the type of transmission "<<endl;;
cout<< " 1 for Auto 2 for Manual : ";
getline(cin,Car[Num_car_system][6]);
if(Car[Num_car_system][6] == "1")
{
running = true;
Car[Num_car_system][6] = "Auto";
break;
}
else if(Car[Num_car_system][6] == "2")
{
running = true;
Car[Num_car_system][6] = "Manual";
break;
}
else
{
cout<< " Please Select 1 or 2 only "<<endl;
!running;
}
}
cout<< " Please enter the cost of car : RM ";
getline(cin,Car[Num_car_system][7]);
cout<<endl;
cout<< " Updated Inventory Successfully... "<<endl<<endl;
cout<< " Back to Main Manu... "<<endl;
Num_car_system++;
getchar();
system("cls");
}
}
}
}
}
if(flag2!=true){
cout<<"No record was found"<<endl;}
}
void Search_existing_car_account(int &Num_car_system, string Car[][8])
{
int option;
string tmp_carmanufacture;
string tmp_carmodel;
string tmp_yearmanufaccturing;
int number=0;
cout<< " Car searching method : "<<endl;
cout<< " 1. Car manufacture / Car make "<<endl;
cout<< " 2. Car model "<<endl;
cout<< " 3. Year of manufacturing "<<endl<<endl;
cout<< " Please enter your option : ";
cin>>option;
if(option==1)
{
cout<< " Please enter the car manufacturer's name : ";
cin>>tmp_carmanufacture;
for(int a=0; a<Num_car_system; a++)
{
if(Car[a][1]==tmp_carmanufacture)
{
cout<< " Car Details... "<<endl;
cout<< " Car Registration Number : "<<Car[a][0]<<endl;
cout<< " Car Brand : "<<Car[a][1]<<endl;
cout<< " Car Model : "<<Car[a][2]<<endl;
cout<< " Car Color : "<<Car[a][3]<<endl;
cout<< " Year Of Manufacturing : "<<Car[a][4]<<endl;
cout<< " Car's Engine Capacity(cc) : "<<Car[a][5]<<endl;
cout<< " Type of Transmission : "<<Car[a][6]<<endl;
cout<< " Cost of Car : RM "<<Car[a][7]<<endl<<endl;
number++;
}
}
if(number==0)
{
cout<<"No record was found"<<endl;
}
}
else if(option==2)
{
cout<< " Please enter the car model's name : ";
cin>>tmp_carmodel;
for(int a=0; a<Num_car_system; a++)
{
if(Car[a][2]==tmp_carmodel)
{
cout<< " Car Details... "<<endl;
cout<< " Car Registration Number : "<<Car[a][0]<<endl;
cout<< " Car Brand : "<<Car[a][1]<<endl;
cout<< " Car Model : "<<Car[a][2]<<endl;
cout<< " Car Color : "<<Car[a][3]<<endl;
cout<< " Year Of Manufacturing : "<<Car[a][4]<<endl;
cout<< " Car's Engine Capacity(cc) : "<<Car[a][5]<<endl;
cout<< " Type of Transmission : "<<Car[a][6]<<endl;
cout<< " Cost of Car : RM "<<Car[a][7]<<endl<<endl;
number++;
}
}
if(number==0)
{
cout<<"No record was found"<<endl;
}
}
else if(option==3)
{
cout<< " Please enter the year of manufacturing : ";
cin>>tmp_yearmanufaccturing;
for(int a=0; a<Num_car_system; a++)
{
if(Car[a][4]==tmp_yearmanufaccturing)
{
cout<< " Car Details... "<<endl;
cout<< " Car Registration Number : "<<Car[a][0]<<endl;
cout<< " Car Brand : "<<Car[a][1]<<endl;
cout<< " Car Model : "<<Car[a][2]<<endl;
cout<< " Car Color : "<<Car[a][3]<<endl;
cout<< " Year Of Manufacturing : "<<Car[a][4]<<endl;
cout<< " Car's Engine Capacity(cc) : "<<Car[a][5]<<endl;
cout<< " Type of Transmission : "<<Car[a][6]<<endl;
cout<< " Cost of Car : RM "<<Car[a][7]<<endl<<endl;
number++;
}
}
if(number==0)
{
cout<<"No record was found"<<endl;
}
}
}
void Search_all_inv(int &Num_car_system, string Car[][8])
{
cout<<endl;
cout<< " There are "<<Num_car_system <<" cars is currently storing in the system"<<endl;
for(int a=0; a<Num_car_system; a++)
{
cout<< " Car Details... "<<endl<<endl;
cout<< " Car Registration Number : "<<Car[a][0]<<endl;
cout<< " Car Brand : "<<Car[a][1]<<endl;
cout<< " Car Model : "<<Car[a][2]<<endl;
cout<< " Car Color : "<<Car[a][3]<<endl;
cout<< " Year Of Manufacturing : "<<Car[a][4]<<endl;
cout<< " Car's Engine Capacity(cc) : "<<Car[a][5]<<endl;
cout<< " Type of Transmission : "<<Car[a][6]<<endl;
cout<< " Cost of Car : "<<Car[a][7]<<endl<<endl;
}