confusing about the additional operations, how to design it ?

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.

_____________________________________________________________________________

#include<iostream>
#include<string>
#include <ctype.h>
using namespace std;

void New_car_account(int &, string [][8]);
void Edit_existing_car_account(int &, string [][8]);
void Remove_existing_car_account(int &, string [][8]);
void Search_existing_car_account(int &, string [][8]);
void Search_all_inv(int &, string [][8]);

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;
}se
{
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");
}

Last edited on
void Edit_existing_car_account(int &Num_car_system, string Car[][8])
{
string temp_car_registration_num;

cout<< " Please enter the car regisration number : ";
cin>>temp_car_registration_num;

for(int a=0; a<Num_car_system; a++)
{
if(Car[a][0] == temp_car_registration_num)
{ bool flag = true;
string choice2;
int choice;
while(flag==true)
{
cout<< " Car Details... "<<endl;
cout<< " 1 : Car Registration Number : "<<Car[a][0]<<endl;
cout<< " 2 : Car Brand : "<<Car[a][1]<<endl;
cout<< " 3 : Car Model : "<<Car[a][2]<<endl;
cout<< " 4 : Car Color : "<<Car[a][3]<<endl;
cout<< " 5 : Year Of Manufacturing : "<<Car[a][4]<<endl;
cout<< " 6 : Car's Engine Capacity(cc) : "<<Car[a][5]<<endl;
cout<< " 7 : Type of Transmission : "<<Car[a][6]<<endl;
cout<< " 8 : Cost of Car : "<<Car[a][7]<<endl<<endl;

cout<< " Which part that you want to edit (Please select 1 - 8) : ";
cin>>choice;

if(choice == 1)
{
cout<< " Car Registration Number : ";
cin>>Car[a][0];
cout<< " Edit successfully"<<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;
}
else if(choice == 2)
{
cout<< " Car Brand : ";
cin>>Car[a][1];
cout<< " Edit successfully"<<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;
}
else if(choice == 3)
{
cout<< " Car Model : ";
cin>>Car[a][2];
cout<< " Edit successfully"<<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;
}
else if(choice == 4)
{
cout<< " Car Color : ";
cin>>Car[a][3];
cout<< " Edit successfully"<<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;
}
else if(choice == 5)
{
cout<< " Year Of Manufacturing : ";
cin>>Car[a][4];
cout<< " Edit successfully"<<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;
}
else if(choice == 6)
{
cout<< " Car's Engine Capacity(cc) : ";
cin>>Car[a][5];
cout<< " Edit successfully"<<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;
}
else if(choice == 7)
{
cout<< " Type of Transmission : ";
cin>>Car[a][6];
if(Car[Num_car_system][6] == "1")
{
Car[Num_car_system][6] = "Auto";
}
else if(Car[Num_car_system][6] == "2")
{
Car[Num_car_system][6] = "Manual";
}
else
{
cout<< " Please Select 1 or 2 only "<<endl;
}
cout<< " Edit successfully"<<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;
}
else if(choice == 8)
{
cout<< " Cost of Car : ";
cin>>Car[a][7];
cout<< " Edit successfully"<<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;
}
else
{
cout<< " Please Enter Selection 1 - 8 ";
}

cout<< " Do you wish to edit this record again?(y/n) : ";
cin>>choice2;
if(choice2=="y")
{
flag=true;
}
else
{
flag=false;
}
}
break;
}
else
{
cout<< " Record not found. "<<endl;
break;
}
}
}
Last edited on
void Remove_existing_car_account(int &Num_car_system, string Car[][8])
{
string temp_car_registration_num;
int selected_index;
bool flag2=false;

cout<< " Please enter the car regisration number : ";
cin>>temp_car_registration_num;

for(int a=0; a<Num_car_system; a++)
{
if(Car[a][0] == temp_car_registration_num)
{
bool flag = true;
string choice3;
int choice;
selected_index=a;
while(flag==true)
{
cout<< " Car Details... "<<endl;
cout<< " 1 : Car Registration Number : "<<Car[a][0]<<endl;
cout<< " 2 : Car Brand : "<<Car[a][1]<<endl;
cout<< " 3 : Car Model : "<<Car[a][2]<<endl;
cout<< " 4 : Car Color : "<<Car[a][3]<<endl;
cout<< " 5 : Year Of Manufacturing : "<<Car[a][4]<<endl;
cout<< " 6 : Car's Engine Capacity(cc) : "<<Car[a][5]<<endl;
cout<< " 7 : Type of Transmission : "<<Car[a][6]<<endl;
cout<< " 8 : Cost of Car : "<<Car[a][7]<<endl<<endl;

cout<< " Do you wish to remove the data?(y/n) : ";
cin>>choice3;

if(choice3 == "y" || choice3 == "Y")
{
for(int b=selected_index; b<Num_car_system; b++){
if(b!=(Num_car_system-1))
{
Car[b][0]=Car[b+1][0];
Car[b][1]=Car[b+1][1];
Car[b][2]=Car[b+1][2];
Car[b][3]=Car[b+1][3];
Car[b][4]=Car[b+1][4];
Car[b][5]=Car[b+1][5];
Car[b][6]=Car[b+1][6];
Car[b][7]=Car[b+1][7];
}
else
{
Car[b][0].clear();
Car[b][1].clear();
Car[b][2].clear();
Car[b][3].clear();
Car[b][4].clear();
Car[b][5].clear();
Car[b][6].clear();
Car[b][7].clear();
}
}
cout<<"Record removed succesfully"<<endl;
Num_car_system--;
flag2=true;
flag=false;
break;
}
else
{
break;

}
}
}
}
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;
}


}

Last edited on
Topic archived. No new replies allowed.