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

For Programming Assignment 3 you will be creating a program to manage a car deal

ID: 3765623 • Letter: F

Question

For Programming Assignment 3 you will be creating a program to manage a car dealership. This will again be a menu driven system. The following is your menu:

number 6 is search by make!!!!!

Please use the code for c++.

Please use the code that I can understand not bunch of the &&&&!%@.

1.Display Inventory

2.Add a vehicle

3.Update a vehicle

4.Delete a vehicle

5.Sort inventory by VIN

6.Search inventory by Make

7.Read inventory from file

8.Write inventory to file and exit

Your program will be class based with the following UML representing the class:

Vehicle

- VIN:string

- make:string

- model:string

- year:int

- price:double

+ Vehicle(iVIN:string, iMake:string, iModel:string, iYear:int, iPrice:double)

+ Vehicle( )

+ getVIN( ):string

+ getMake( ):string

+ getModel( ):string

+ getYear( ):int

+ getPrice( ):double

+ setVIN(input:string):void

+ setMake(input:string):void

+ setModel(input:string):void

+ setYear(input:int):void

+ setPrice(input:double):void

You will have four files for your program (I want these file names!): main.cpp, functions.h, vehicle.h, vehicle.cpp.

main.cpp: this will be your driver file.

functions.h: this will contain your global functions for each of the menu items (display, addVehicle, deleteVehicle, updateVehicle, etc).

vehicle.h: this will contain the class declaration. vehicle.cpp: this will contain the class implementation.

You will be storing your vehicle objects in a vector. In the main function, you will create a vector of vehicles with an initial size of zero (0). When the menu options display, delete, edit, sort, or search are called, you will have to check your vector and ensure that it has a vehicle in it before the function continues (error checking).

You will not have any global variables.

Each menu item will have a corresponding function, and the definition of the function will be found in the file functions.h. Each function will only have one parameter, the vector. All I/O will be done in the functions and not in main (expect asking for what menu option the user wants).

The following are the details for each of your menu options:

1. You will display each vehicle, using the following format: Vehicle: # VIN: VVVV Make: MMMM Model: MMMM Year: YYYY Price: $D.CC The bold face letters represent the values for the individual vehicle, and it doesn’t have to be bolded. Notice the tab stop between the label and the value. Also notice that there is a dollar sign and decimal for the price. Lastly, for Vehicle: #, the pound sign represents the vehicle position number in the vector (starting at 1 not 0), which will be 1, 2, 3 … and so on.

2. You will ask the user for all of the information to add the vehicle and then you will add it to the vector.

3. You will display the vehicles and then ask the user which vehicle to edit; they will give you the index number (starting at 1). Check to ensure they gave you a valid entry, then prompt for which item they want to edit (year, make, model, price, or VIN). Once they make their selection prompt for the new information, then return to the main menu.

4. You will display the vehicles and then ask the user which vehicle to delete: they will give you the index number (starting at 1). You will then check to ensure they gave you a valid entry and then remove that vehicle from the vector.

5. You will sort the vector by VIN number (when sort is done, the vector in main will be sorted by VIN number).

6. You will ask the user for a make, then search the vector for that vehicle. You will return the first matching entry’s index number or an appropriate message if not found.

7. You will read the inventory from a file called inventory.dat, which is NOT provided for you (you will need to make your own to start with). The data is stored in the same order as listed above and it is newline delimited.

8. You will write the entire inventory out to a file called inventory.dat and then exit the program.

Explanation / Answer

Main.cpp

#include "functions.h"
using namespace std;
int main()
{
int var;
vector<string> vehicle;
{
string vin;
string make;
string model;
int year;
double price;
};
var = '1';
var = '2';
var = '3';
var = '4';
var = '5';
var = '6';
var = '7';
var = '8';
do
{
cout << "Please select an operation: ";
cout << "1: Display Inventory ";
cout << "2: Add a vehicle ";
cout << "3: Update a vehicle ";
cout << "4: Delete a vehicle ";
cout << "5: Sort inventory by VIN ";
cout << "6: Search inventory from file ";
cout << "7: Read inventory from file ";
cout << "8: Write inventory to file and exit ";
cin >> var;
switch (var)
{
case 1:
{
void displayInventory();
}
break;
case 2:
{
void addToInventory();
}
break;
case 3:
{   
void updateInventory();
}
break;
case 4:
{   
void deleteInventory();
}
break;
case 5:
{   
void sortVehicle();
}
break;
case 6:
{   
void searchInventory();
}
break;
case 7:
{
string vin;
string make;
string model;
int year;
double price;
getline(infile, vin);
getline(infile, make);
getline(infile, model);
getline(infile, year);
getline(infile, price);
}
break;
case 8:
{
void searchInventory();
}
break;
default:
{
cout << "Please enter a number between 1 and 8. ";
}
break;
};
}
while (var != 8);
system("pause");
return 0;
}

Functions.h

#ifndef FUCNTION_H
#define FUCNTION_H
#include <iostream>
#include <string>
#include <stdlib.h>
#include <fstream>
#include "vehicle.cpp"
#include "vehicle.h"
#include <vector>
using namespace std;
vector<string> vehicle;
{
string vin;
string make;
string model;
int year;
double price;
};
int i;
void displayInventory()
{
int i;
double MAX_SIZE = 100;
if (i > !MAX_SIZE)
{
cout << "Error: There is no more room to add entries. You will now be returned to the main menu." << endl;
}
else (i = 0, i < MAX_SIZE, i++);
{
cout << vehicle[i].getvin();
cout << vehicle[i].getmake();
cout << vehicle[i].getmodel();
cout << vehicle[i].getyear();
cout << vehicle[i].getprice();
}
};
void addToInventory()
{
int input;
int i;
double MAX_SIZE = 100;
do (i = 0, i < MAX_SIZE, i++)
{
cout << "Here you can add a vehicle to the database. " << endl;
cout << "Please enter the VIN number. " endl;
cin >> vehicle[i].setvin(); << endl;
cout << "Please enter the vehicle make ";
cin >> vehicle[i].setmake(); << endl;
cout << "Please enter the vehicle model ";
cin >> vehicle[i].setmodel(); << endl;
cout << "Please enter the vehicle year ";
cin >> vehicle[i].setyear(); << endl;
cout << "Please enter the vehicle price ";
cin >> vehicle[i].setprice(); << endl;
vehicle.push_back;
cout << "Enter a Y if you would like to input more data ";
cin >> input;
}
while (toupper(input) == 'Y');
if (i >! MAX_SIZE)
{
cout << "Error: There is no more room to add entries. You will now be returned to the main menu." << endl;
}
};
void updateInventory()
{
int i;
cout << "You are about to update an entry. ";
cout << "Choose a vehicle number from the inventory: ";
void displayInventory();
cin >> i;
i = i - 1;
cout << "What would you like to update? ";
cout << "1: Vehicle VIN ";
cout << "2: Vehicle Make ";
cout << "3: Vehicle Model ";
cout << "4: Vehicle Year ";
cout << "5: Vehicle Price ";
switch (var)
{
case 1:
{
cout << "Please enter the updated VIN: " << endl;
cin >> vehicle[i].setvin();
return 0;
}
break;
case 2:
{
cout << "Please enter the updated make: " << endl;
cin >> vehicle[i].setmake();
return 0;
}
break;
case 3:
{
cout << "Please enter the updated model: " << endl;
cin >> vehicle[i].setmodel();
return 0;
}
break;
case 4:
{
cout << "Please enter the updated year: " << endl;
cin >> vehicle[i].setyear();
return 0;
}
break;
case 5:
{
cout << "Please enter the updated price: " << endl;
cin >> vehicle[i].setprice();
return 0;
}
break;
default:
{
cout << "Please enter a number between 1 and 5. ";
}
break;
};
};
void deleteInventory()
{
cout << "You are about to delete an entry. ";
cout << "Choose a vehicle number from the inventory: ";
void displayInventory();
cin >> i;
i = i - 1;
vehicle.erase[i];
};
void sortVehicle()
{
vehicle temp;
int number = myVector.size();
for (int i = 0; i < number; i++)
{
if (myVector[i + 1].getvin() < myVector[i].getvin())
{
temp = myVector[i];
myVector[i] = myVector[i + 1];
myVector[i + 1] = temp;
}
}
};
void searchInventory()
{
vector<string> vehicle;
{
string vin;
string make;
string model;
int year;
double price;
};
int size = vehicle.size();
string searchModel;
cout << "Please type the model you'd like to search for: " << endl << endl;
cin >> searchModel;
for (int i = 0, i > size, i++)
{
vehicle[i].getmake();
}
if (vehicle[i].getmake() = vehicle.make)
{
cout << vehicle[i];
}
};


vehicle.cpp

#include "vehicle.h"
vehicle::vehicle()
{
vin = "65E";
make = "audi";
}
vehicle::vehicle(string ivin, string imake, string imodel, int iyear, double iprice)
{
vin = ivin;
make = imake;
model = imodel;
year = iyear;
price = iprice;
}
string vehicle::getvin() const
{
return vin;
}
string vehicle::getmake() const
{
return make;
}
string vehicle::getmodel() const
{
return model;
}
int vehicle::getyear() const
{
return year;
}
double vehicle::getprice() const
{
return price;
}


vehicle.h

class vehicle
{
private:
string vin;
string make;
string model;
int year;
double price;
public:
vehicle();
vehicle(string, string, string, int, double);
string getvin() const;
string getmake() const;
string getmodel() const;
int getyear() const;
double getprice() const;
void setvin(string);
void setmake(string);
void setmodel(string);
void setyear(int);
void setprice(double);
};

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