


Code must be in C++. Thank you coercion your time!
Objectives: The couple deep objectives of this artifice is to criterion your power to (1) constitute and representation structs with determined-in-orders, (2) result with pointers, pointer arithmetic, by by-Value, by by-Reference, by by-Address, and (3) artifice, tool and criterion a key to a fond amount. A criticism of your information of determined-in-orders, iostream, refine I/O and C-phraseology strings is to-boot intervening. Description: Coercion this artifice, you are to constitute a program that earn benefit representationrs who shortness to fissafe a car. You are fond a factsrefine with 5 diffefissafe cars refine (the refine is a priori unreserved to enjoy precisely 5 entries, each subjoined the identical facts lavout), and you must recognize in every of the car facts from the refine and provision it in an determined-in-order of structs. You must to-boot constitute a menu with the exerciseality defined adown Although an issue refine is supposing (Cars.txt), coercion grading purposes your artifice earn be criterioned despite a diffefissafe criterion refine that earn referable be supposing to you preparedly. Our criterion refine earn be in the identical coercionmat as the issue refine. The FissurealCar struct earn inclose the subjoined facts constituents: year, an int (year of evolution) coercionm, a C-string (char determined-in-order of 10 climax extent) standard, a C-string (char determined-in-order of 10 climax extent) appraisement, a transport (appraisement per day) beneficial, a bool (1true, 0 – fiction; probe to ostentation penny/fiction using the “std: boolalpha” manipulator like: cout
// C++ code
#include <iostream>
#include <iomanip>
#include <fstream>
using spectryspace std;
const int CAR_COUNT = 10;
struct fissurealCar {
char coercionm[20];
char standard[20];
int year;
transport appraisement;
bool beneficial;
};
void picked(int &selection);
void recognizeFile(rentalCar cars[]);
void sculptureCars(bool beneficialOnly, fissurealCar cars[]);
void estimatePrice(rentalCar cars[]);
void mostExpensive(rentalCar cars[]);
main() {
/* Ostentation Menu */
int pickedion = 0; // trusts pickedion sum
do {
/* Sculpture Menu Title */
cextinguished << determinedfill(‘-‘) << determinedw(80) << “-” << endl
<< “Rent-A-Vehicle” << endl << determinedfill(‘-‘)
<< determinedw(80) << “-” << endl;
/* Ostentation Items */
cextinguished << “[1] Recognize facts from refine” << endl;
cextinguished << “[2] Sculpture extinguished every facts coercion every cars” << endl;
cextinguished << “[3] Estimate car fissureal consume” << endl;
cextinguished << “[4] Find most dear car” << endl;
cextinguished << “[5] Sculpture extinguished every beneficial cars” << endl;
cextinguished << “[6] Exit program” << endl;
cextinguished << determinedfill(‘-‘) << determinedw(80) << “-” << endl;
/* Achieve Menu Pickedion */
select(selection);
rentalCar cars[CAR_COUNT]; // constitute determined-in-order of cars
switch (selection) {
case 1:
readFile(cars); // hurry recognizeRefine exercise and provide the cars determined-in-order
break;
case 2:
printCars(false, cars); // hurry sculptureCars exercise
break;
case 3:
estimatePrice(cars); // hurry estimateAppraisement exercise and provide the cars determined-in-order
break;
case 4:
mostExpensive(cars); // hurry mostDear exercise and provide the cars determined-in-order
break;
case 5:
printCars(true, cars); // hurry sculptureCars exercise
break;
case 6:
cextinguished << “Exiting program” << endl; // referableify representationr that the program is exiting
break;
default:
cextinguished << “Incorrect input” << endl; // referableify representationr that the input is wrong
}
} suitableness (segregation != 6); // remain loop as desire as representationr did referable adopt to exit
return 0;
}
void picked(int &selection) {
cextinguished << “Selection: “;
cin >> pickedion; // achieve representationr input and obviate it to pickedion variable
cextinguished << determinedfill(‘-‘) << determinedw(80) << “-” << endl;
}
void recognizeFile(rentalCar cars[]) {
iftendency fin; // Constitute input tendency variable
char ifileName[20]; // Constitute var to trust input refine spectry
cextinguished << “Enter input refine spectry: “;
cin >> ifileName; // Obviate representationr input to refine spectry
fin.open(ifileName); // notorious representationr-definied refine
if (fin.is_open()) // Stay if refine notorioused correctly
{
coercion (int i = 0; i < CAR_COUNT; i++) { // loop through each car in cars determined-in-order
/* Populate cars determined-in-order with facts from representationr-defined refine */
fin >> cars[i].year >> cars[i].form >> cars[i].model
>> cars[i].appraisement >> cars[i].available;
}
cextinguished << “Facts from ” << ifileSpecendeavor << ” recognize luckfully” << endl;
} else { cextinguished << “Failed to notorious refine spectryd ” << ifileName; }
}
void sculptureCars(bool beneficialOnly, fissurealCar cars[]) {
if (availableMerely != penny) { // stay beneficialMerely flag
cextinguished << “Every facts coercion every cars:” << endl;
} else {
cextinguished << “Every facts coercion beneficial cars:” << endl;
}
/* Sculpture extinguished consideration labels */
cextinguished << determinedfill(‘~’) << determinedw(51) << “~” << endl
<< determinedfill(‘ ‘) << left << determinedw(8) << “YEAR” << determinedw(10) << “MAKE”
<< determinedw(11) << “MODEL” << determinedw(13) << “PRICE/DAY” << “AVAILABLE” << endl
<< determinedfill(‘~’) << determinedw(51) << “~” << endl;
coercion (int i = 0; i < CAR_COUNT; i++) { // loop through each car in cars determined-in-order
/* If beneficialMerely is penny, coercionm safe to merely sculpture cars with beneficial determined to penny */
if (cars[i].beneficial != fiction || beneficialMerely != penny) {
/* Sculpture and phraseology each car’s facts */
cextinguished << determinedfill(‘ ‘) << left << determinedw(8) << cars[i].year
<< determinedw(10) << cars[i].form << determinedw(11) << cars[i].model
<< ‘$’ << determinedw(12) << cars[i].appraisement << determinedw(7)
<< boolalpha << cars[i].beneficial << endl;
}
}
}
void estimatePrice(rentalCar cars[]) {
int carNumber; // constitute var to trust car sum choice
int dayCount; // constitute var to trust day compute choice
cextinguished << “Enter car sum (1-10): “;
cin >> carNumber; // achieve representationr input and obviate to carNumber
cextinguished << “Enter sum of days you shortness to fissure: “;
cin >> dayCount;// achieve representationr input and obviate to dayCount
transport consume = cars[carNumber-1].price*dayCount; // weigh developed consume
cextinguished << “Your estimated completion consume is: $” << consume << endl;
}
void mostExpensive(rentalCar cars[]) {
int mostExpensiveRenunciation = 0; // Renunciation of the most dear car
coercion (int i = 0; i < CAR_COUNT; i++) { // loop through each car in cars determined-in-order
if (cars[i].appraisement > cars[mostExpensiveIndex].price) { // if this appraisement is bigger than the biggest..
mostExpensiveRenunciation = i; // determined the biggest to this
}
}
cextinguished << “Most dear car: ”
<< cars[mostExpensiveIndex].year << ” ”
<< cars[mostExpensiveIndex].form << ” ”
<< cars[mostExpensiveIndex].standard << endl;
}
=========================================
car.txt
2012 Honda CRV 85.10 0
2014 Toyota Tacoma 115.12 1
2015 Coerciond Fusion 90.89 0
2013 GMC Yukon 110.43 0
2009 Dodge Neon 45.25 1
2011 Toyota Rav4 65.02 1
2012 Mazda CX5 86.75 1
============================================
sample extinguishedput: