Hello, currently working on an rental system for fun, when input the data and try to recall it using arrays it seems not to be working ill post the code below
#include <iostream>
#include <string>
usingnamespace std;
class automobile {
public :
string car_registration;
int total_miles_driven;
int tank_filling_accumulation;// litres
int number_of_repairs;
int tax_rate;
int insurance_group;
int tyre_change_count;
int seats;
int users;
string fuel_type;
int fuel_size;
void MPG();
void NORPM();
void AMPU();
};
void automobile::MPG()
{
float mpg;
mpg = total_miles_driven/tank_filling_accumulation;
cout << "The miles per a gallons achieved was" << mpg << endl;
}
void automobile::NORPM()
{
float repairs;
repairs = total_miles_driven/number_of_repairs;
cout << "The number of repairs per miles is:" << repairs << endl;
}
void automobile::AMPU()
{
int APU;
APU = total_miles_driven/users;
cout << "The average miles per a user is:" << APU << endl;
}
class sportscars : public automobile {
public:
bool softtop;
bool alloys;
sportscars(){
seats = 2;
tax_rate = 210;
insurance_group = 16;
fuel_type = "Petrol";
}
void sportscars_entry();
void displaysports_cars();
};
void sportscars::displaysports_cars()
{
cout << " SportsCars Stats";
cout << " The SportsCars Registration is:" << car_registration;
cout << " The SportCar has driven a total of:" << total_miles_driven;
cout << " The tank filling accumulation is:" << tank_filling_accumulation;
cout << " Numer of repairs :" << number_of_repairs;
cout << " Tax Rate :" << tax_rate;
cout << " Insurance group :" << insurance_group;
cout << " Amount of tyre changes:" << tyre_change_count;
cout << " The amount of seats the sport cars has is:" << seats;
cout << " The fuel type is " << fuel_type;
cout << " The fuel size is " << fuel_size;
}
void sportscars :: sportscars_entry()
{
cout << " SportsCars Entry";
cout << " Can you please enter the car registration:";
cin >> car_registration;
cout << " How many miles has the car driven:";
cin >> total_miles_driven;
cout << " How big is the tank of the sports car:";
cin >> tank_filling_accumulation;
cout << " How many repairs has the car had done: :";
cin >> number_of_repairs;
cout << " Please type the Tax Rate :";
cin >> tax_rate;
cout << " What Insurance group is the car: :";
cin >>insurance_group;
cout << " How many tyre changes has the car had: :";
cin >> tyre_change_count;
cout << " How many seats does the sportscar had::";
cin >>seats;
cout << " What fuel does the car use: ";
cin >> fuel_type;
cout << " How big is the size of the fuel tank: ";
cin >> fuel_size;
}
class FbyF : public automobile {
public:
bool towing_hitch;
bool road_pack;
FbyF()
{
seats = 5-7;
tax_rate = 440;
insurance_group = 12;
fuel_type = "Diesel";
}
void FbyF_entry();
void display_FbyF_entry();
};
void FbyF :: display_FbyF_entry() {
cout << " FbyF stats";
cout << " The FbyF Registration is:" << car_registration;
cout << " The has driven a total of:" << total_miles_driven;
cout << " The tank filling accumulation is:" << tank_filling_accumulation;
cout << " Numer of repairs :" << number_of_repairs;
cout << " Tax Rate :" << tax_rate;
cout << " Insurance group :" << insurance_group;
cout << " Amount of tyre changes:" << tyre_change_count;
cout << " The amount of seats the sport FbyF has is:" << seats;
cout << " The fuel type is " << fuel_type;
cout << " The fuel size is " << fuel_size;
}
void FbyF :: FbyF_entry() {
cout << " FbyF Entry";
cout << " Can you please enter the car registration:";
cin >> car_registration;
cout << " How many miles has the car driven:";
cin >> total_miles_driven;
cout << " How big is the tank of the FbyF car:";
cin >> tank_filling_accumulation;
cout << " How many repairs has the car had done: :";
cin >> number_of_repairs;
cout << " Please type the Tax Rate :";
cin >> tax_rate;
cout << " What Insurance group is the car: :";
cin >>insurance_group;
cout << " How many tyre changes has the car had: :";
cin >> tyre_change_count;
cout << " How many seats does the FbyFcar had::";
cin >>seats;
cout << " What fuel does the car use: ";
cin >> fuel_type;
cout << " How big is the size of the fuel tank: ";
cin >> fuel_size;
}
class vans : public automobile {
public:
bool hight_top;
int Capacity;
vans()
{
seats = 3;
tax_rate = 225;
insurance_group = 11;
fuel_type = "Diesel";
}
void vans_entry();
void display_vans_entry();
};
void vans :: display_vans_entry() {
cout << " Vans stats";
cout << " The Vans Registration is:" << car_registration;
cout << " The has driven a total of:" << total_miles_driven;
cout << " The tank filling accumulation is:" << tank_filling_accumulation;
cout << " Numer of repairs :" << number_of_repairs;
cout << " Tax Rate :" << tax_rate;
cout << " Insurance group :" << insurance_group;
cout << " Amount of tyre changes:" << tyre_change_count;
cout << " The amount of seats the sport vans has is:" << seats;
cout << " The fuel type is " << fuel_type;
cout << " The fuel size is " << fuel_size << endl;
}
void vans :: vans_entry() {
cout << " vans Entry";
cout << " Can you please enter the car registration:";
cin >> car_registration;
cout << " How many miles has the car driven:";
cin >> total_miles_driven;
cout << " How big is the tank of the vans car:";
cin >> tank_filling_accumulation;
cout << " How many repairs has the car had done: :";
cin >> number_of_repairs;
cout << " Please type the Tax Rate :";
cin >> tax_rate;
cout << " What Insurance group is the car: :";
cin >>insurance_group;
cout << " How many tyre changes has the car had: :";
cin >> tyre_change_count;
cout << " How many seats does the van had::";
cin >>seats;
cout << " What fuel does the car use: ";
cin >> fuel_type;
cout << " How big is the size of the fuel tank: " <<endl;
cin >> fuel_size;
}
class booking {
public:
int date_booked_out;
int number_of_days_booked;
string car_registration;
void data_input();
void display_booking();
};
int main()
{
sportscars temp, sportcars_Arry[10];
vans temp2, vans_Arry[10];
FbyF temp3, FbyF_Arry[10];
int sc_count=0, van_count=0, FbyF_count=0;
int choice, choice2,choice3;
homescreen:cout << "Welcome to the Car Rental System" << endl;
cout<< "1. Data Entry"<<'\n';
cout<< "2. Stats Display"<< '\n';
cin>> choice;
switch (choice)
{
home1: case 1:
{ cout << "1. SportsCar"<<'\n';
cout<< "2. Van"<<'\n';
cout<< "3. FbyF"<<'\n';
cout<< "4. Return to Home Screen"<<'\n';
cout<< "5. Exit"<<'\n';
cout<<"Enter your choice"<<'\n';
cin>> choice2;
if (choice2 == 1)
{
sportcars_Arry[sc_count].sportscars_entry();
sc_count++;
goto home1;
cout << "thanks for entering the data";
}
elseif (choice2 == 2)
{
vans_Arry[ van_count].vans_entry();
van_count++;
cout << "thanks for entering the data";
goto home1;
}
elseif (choice2 == 3)
{
FbyF_Arry[FbyF_count].FbyF_entry();
FbyF_count++;
cout << "thanks for entering the data";
goto home1;
}
elseif (choice2 == 4)
{
goto homescreen;
}
elseif (choice2 == 4)
{
return 0;
}
break;
}
case 2:
{
cout << "Stats Display screen"<<'\n';
cout << "1. SportsCar Display"<<'\n';
cout<< "2. Van Display"<<'\n';
cout<< "3. FbyF Display"<<'\n';
cout<<"Enter your choice: ";
cin >> choice3;
if (choice3 == 1)
{
string t_cr;
cout<< "Enter the registration no: "<< t_cr;
cin >> t_cr;
for(int i=0; i<sc_count;i++)
{
if (sportcars_Arry[i]. car_registration == t_cr)
sportcars_Arry[i].displaysports_cars();
else{
cout<< "No sports car exists with the specified registration number ...!!!";
}
}
}
elseif (choice3 = 2)
{
}
elseif (choice3 = 3)
{
}
break;
}
}
system("pause");
return 0;
}