Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in C++ to maintain an inventory for a small used vehicle dealer

ID: 3662396 • Letter: W

Question

Write a program in C++ to maintain an inventory for a small used vehicle dealer (Please show proof that program works).The C++ program should maintain and display a list of vehicles , should calculate the sales price and monthly payments for a designated vehicle.

The class should have data elements for the following info: Make,Model,color,mileage,fuelconsumption and list price. The following will be derived classes from the vehicle: Automobile,motorcycle. Program will need to have functions to : add miles to the mileage from test drives or employee use and another separate function to subtract/decrease the mileage. Program will also need a List class. The List class will use a dynamic array to store Vehicle objects. Program will have one list for Automobiles and one for Motorcycles. Program will NEVER have an object of class Vehicle. As each vehicle is entered an object of the appropriate type must be created and added to the correct array. Remember you may need to increase the size of the array. Start each array with 2 elements so the grader can test your resizing. Double the size each time you increase capacity. Program must perform the following activities: create a list, add items, search for a vehicle, calculate the price and payments for a vehicle, remove a vehicle, and display the inventory. Some of these should be member functions of the List class, and which will be functions in your program. The user should be able to search for any attribute (data member) of the Vehicle, Automobile, or Motorcycle classes. To add an item you should prompt the user to enter the required information.

Check the input when adding a vehicle (input validation). Transmissions should be AT, CVT, and MT. The boss definitely doesn’t want negative prices, but also doesn’t want a vehicle sitting because an extra 0 got put in the price. So anything over $10,000 requires an acknowledgement. What else to check Your program should calculate the final price of the vehicle. There is only 1 list price. When the user selects a vehicle to purchase you start with the list price, you can deduct any incentives (just entered by the user), add a $95 administrative fee, add any taxes, deduct the amount of the trade-in (if any), enter an interest rate and loan period to calculate* the monthly payment. Display each of these values to the user. Give them the option to indicate the vehicle sold. If it is sold remove it from the inventory. The display should show: Menu of choices (display all vehicles in the inventory, adjust mileage for a vehicle, search for a vehicle, add a vehicle, calculate purchase price for a vehicle, and exit. The calculate price option should remove the vehicle if it was sold. The search should display the information for each vehicle matching the criteria.

Explanation / Answer

program :   

#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
class CarInventory
{
private:
string make;
string model;
string Acc;
string Mut;
string vin;
string engine_size;
int year;
float dealer_cost;
float dealer_price;
char exterior_color[15];
char interior_color[15];
void check_price();
public:
friend bool operator ==(CarInventory& Auto, CarInventory& Inventory);
void initArrays();
void set_make();
void set_model();
void get_make();
void get_model();
void get_year();
void get_dealer_cost();
void get_dealer_price();
void get_exterior_color();
void get_interior_color();
void get_vin();
void get_engine_size();
void output_info(ostream& outs, CarInventory& Inventory);
void delete_car();
void add_car(istream& ins, CarInventory& Inventory);
int search();
int menu();
};
int main()
{
CarInventory Inventory[100],Auto;
int menu();
bool yes = true;
while(yes = true)
{
switch(menu())
{
case 1:
Inventory[100].add_car(cin, *Inventory);   
break;
case 2:
Inventory[100].delete_car();
break;
case 3:
Inventory[100].search();
break;
case 4:
exit(0);
break;
}
}
return 0;
}
int menu()
{ int selection;
cout<< "(1) Enter to add cars .......:" << endl;
cout<< "(2) Enter to delete cars.....:" << endl;
cout<< "(3) Enter to search cars.....:" << endl;
cout<< "(4) Enter to exit............:" << endl;
cout<< "Please enter selection.......:" << endl;
cin>> selection;
cout << endl;
while((selection < 1 || selection > 4))
{
cout << "Wrong selection please try again. Enter 1,2,3,4 or 5" << endl;
cin>> selection;
}
return selection;
}
bool operator == (CarInventory &Auto, CarInventory &Inventory)
{
return(Auto.make == Inventory.make);
}
void CarInventory::check_price()
{
if(dealer_price < 0.0 || dealer_cost < 0.0)
{
cout<<"Wrong Price please enter right price...:"<< endl;
exit(0);
}
}
void CarInventory::set_make()
{
Acc = make;
}
void CarInventory::set_model()
{
Acc = model;
}
void CarInventory::initArrays()
{
for(int i = 0; i < 100; i++)
{
make[i] = '#';
model[i] = '#';
}
}
void CarInventory::get_make()
{
cin >> make;
Mut = make;
}
void CarInventory::get_model()
{
cin >> model;
Mut = model;
}
void CarInventory::add_car(istream& ins, CarInventory& Inventory)
{
int i=0, number_of_cars;
cout << " how many cars do you want to Inventory? " << endl;
cin >> number_of_cars;
while( i < number_of_cars)
{
cout << "Enter the make of the car. " << endl;
ins >> Inventory.make;
cout << "Enter the model of the car. " << endl;
ins >> Inventory.model;
cout << "Enter the year of the car. " << endl;
ins >> Inventory.year;
cout << "Enter the dealer cost. " << endl;
ins >> Inventory.dealer_cost;
cout << "Enter the dealer price. " << endl;
ins >> Inventory.dealer_price;
cout << "Enter the exterior color of the car. " << endl;
ins >> Inventory.exterior_color;
cout << "Enter the interior color of the car. " << endl;
ins >> Inventory.interior_color;
cout << "Enter the Vin number of the car. " << endl;
ins >> Inventory.vin;
cout << "Enter the engine size of the car. " << endl<< endl;
ins >> Inventory.engine_size;
i++;
}cout << "The number of cars in inventory is " << number_of_cars << endl;
}
void CarInventory::output_info(ostream &outs, CarInventory& Inventory)
{
outs<<"Make...........: "<< Inventory.make<< endl;
outs<<"Model..........:"<< Inventory.model<< endl;
outs<<"Year...........:"<< Inventory.year<< endl;
outs<<"Interior Color.:"<< Inventory.interior_color<< endl;
outs<<"Exterior Color.:"<< Inventory.exterior_color<< endl;
outs<<"Vin............:"<< Inventory.vin<< endl;
outs<<"Engine Size....:"<< Inventory.engine_size<< endl;
outs<<"Dealer Cost....:" << Inventory.dealer_cost<< endl;
outs<<"Dealer Price...:"<< Inventory.dealer_price << endl << endl;
}
void CarInventory:: delete_car()
{
CarInventory Inventory[100];
int car_num;
char choice;
int item, i=0;
cout << "enter inventory number of the car you want to delete?" << endl;
cin >> car_num;
item = car_num - 100;
cout << "comfirm delete" << item << " ? (y/n)";
cin >> choice;
if (choice == 'y')
for (int count = item; count+1 < i + 1; count++)
Inventory[count] = Inventory[count + 1];
Inventory[i].initArrays();
}
int CarInventory::search()
{
CarInventory Inventory[100], Auto;
int choice, count, i = 2;
cout << "(1) Enter Make of car...:" << endl;   
cout << "(2) Enter Model of car..:" << endl;
cout << "(3) Display all cars....:" << endl;
cout << "(4) Enter to exit....:" << endl << endl;
cin >> choice;
switch(choice)
{
case 1:
cout << "Enter Make of car:"<< endl;
Auto.get_make();
for (count = 1; count < i; count++)
{ Inventory[count].Acc;
if(Auto == Inventory[count])
cout <<"Match found" << 100 + count << count << endl;
else
cout << "Match not found, try again."<< endl;
}
break;
case 2 :
cout << "Enter Model of car:";
Auto.get_model();
for (count = 1; count < i; count++)
{
Inventory[count].Mut;
if(Auto == Inventory[count])
cout <<"Match found" << count<< endl;
else
cout << "Match not found, try again."<< endl;
}
break;
case 3:
Auto.output_info(cout, *Inventory);
break;
case 4:
exit(0);
break;
}
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote