Question: I ' m not sure where to put the inventory list of vehicles correctly and I need to list them as is in the program
Im not sure where to put the inventory list of vehicles correctly and I need to list them as is in the program with the current inventory
Acura,Integra,
Alfa Romeo,Giulia,
Cadillac,CT
Chevrolet,Bolt,
Dodge,Hornet,
Honda,CRV
Hyundai,Santa Fe
Infiniti,Q
Kia,Carnival,
the code is;
#include #include #include #include #include using namespace std; struct Car int id; int year; string make; string model; double cost; bool isAvailable; bool isRemoved; ; vector inventory; Function declarations void greetAgent; void displayMenu; void loadInventoryconst string &filename; void saveInventoryconst string &filename; void viewInventory; void addCar; void rentCar; void returnCar; void removeCar; int main greetAgent; ifstream filecurrentCarInventorytxt; if fileisopen loadInventorycurrentCarInventorytxt; else loadInventorycarInventorytxt; int choice; do displayMenu; cin choice; cin.ignore; switch choice case : viewInventory; break; case : addCar; break; case : rentCar; break; case : returnCar; break; case : removeCar; break; case : saveInventorycurrentCarInventorytxt; cout "Inventory saved. Exiting program.
; break; default: cout "Invalid choice. Please try again.
; while choice ; return ; void greetAgent cout "Welcome to the Rental Car Inventory Management System!
; void displayMenu cout
User Menu:
; cout View inventory
; cout Add new car to inventory
; cout Rent car to customer
; cout Process returned vehicle
; cout Remove discontinued car from inventory
; cout Quit
; cout "Enter your choice: ; void loadInventoryconst string &filename ifstream inFilefilename; if inFile cout "Failed to open filename for reading.
; return; inventory.clear; Car car; while inFile car.id car.year car.make car.model car.cost car.isAvailable true; car.isRemoved false; inventory.pushbackcar; inFile.close; void saveInventoryconst string &filename ofstream outFilefilename; if outFile cout "Failed to open filename for writing.
; return; for const auto &car : inventory if car.isRemoved outFile car.id car.year car.make car.model fixed setprecision car.cost
; outFile.close; void viewInventory cout
Current Inventory:
; cout left setwID setw "Year" setw "Make" setw "Model" setw "Cost" "Status
; for const auto &car : inventory if car.isRemoved cout left setw car.id setw car.year setw car.make setw car.model $ setw car.cost carisAvailable "Available" : "Rented"
; void addCar Car newCar; cout "Enter car ID: ; cin newCar.id; for const auto &car : inventory if carid newCar.id && car.isRemoved cout "Car with this ID already exists in inventory.
; return; cout "Enter year: ; cin newCar.year; cout "Enter make: ; cin newCar.make; cout "Enter model: ; cin newCar.model; cout "Enter cost: ; cin newCar.cost; newCar.isAvailable true; newCar.isRemoved false; inventory.pushbacknewCar; cout "Car added successfully.
; void rentCar int id; cout "Enter car ID to rent: ; cin id; for auto &car : inventory if carid id && car.isRemoved if carisAvailable car.isAvailable false; int days; cout "Enter number of rental days: ; cin days; double totalCost days car.cost; cout "Collect payment: $ fixed setprecision totalCost
; return; else cout "Car is currently rented.
; return; cout "Car not found in inventory.
; void returnCar int id; cout "Enter car ID to return: ; cin id; for auto &car : inventory if carid id && car.isRemoved if car.isAvailable car.isAvailable true; cout "Car returned successfully.
; return; else cout "Car was not rented.
; return; cout "Car not found in inventory.
; void removeCar int id; cout "Enter car ID to remove: ; cin id; for auto &car : inventory if carid id && car.isRemoved car.isRemoved true; cout "Car removed from inventory.
; return; cout "Car not found in inventory.
;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
