Question: ( Using C++ ) ** Solve WITHOUT using -> operator ** . . Define the class Car which has the following private members: brand: e.g.

( Using C++ ) ** Solve WITHOUT using -> operator **
. . Define the class Car which has the following private members: brand: e.g. Toyota, Honda etc. model: e.g. Camry, Civic, etc. consumption: giving the number of liters of petrol the car consumes per kilometer (2 to 18) kilometers: giving the number of kilometers the car has run since its production (10 to 1000) petrolPrice: a decimal number giving the price of one liter of petrol in dirham (20 to 35) age: giving the age of the car in days since its production (100 to 250) and the following public members: a default constructor (without parameters) a parameterized constructor a set() function which sets all the data member values. This function should check the validity of the last 4 data members, setting the value to 0 if not satisfied. a get() function which returns the values of all the data members. a function averageKmsPerDay() which returns the average number of kilometers a car has traveled per day (kilometers / age) a function averageLtsPerDay( which returns the daily average petrol consumption of a car in dirham (kilometers * consumption * petrolPrice / age) a function print() which prints a car object details in the given format. . . 1 Implement the member functions of the class Car enforcing the least privileged principle. Create a project containing the class interface in a header file (car.h), the class implementation in a carImp.cpp file and the main program in a car.cpp file. The following driver produces the given sample of input/output: int main() { string objectBrand, objectModel; int objectConsumption, objectKilometers, objectAge; double objectPetrolPrice; Car myCar; Car NiceCar("Honda", "Civic", 11, 453, 123, 21.25); cout > objectBrand; cout > objectModel; cout > objectConsumption; cout > objectKilometers; cout > objectAge; cout > objectPetrolPrice; myCar.set(objectBrand, objectModel, objectConsumption, objectKilometers, objectAge, objectPetrolPrice); myCar.print(); NiceCar.print(); return 0; } Sample input / output: Enter the brand of the car: Toyota 2/3 Enter the model of the car: Corola Enter the petrol consumption: between 3 and 18:13 Enter the kilometers: between 10 and 1000: 340 Enter the age: between 100 and 250: 140 Enter the petrol price: between 20 and 35: 22 Brand is Toyota, Model is Corola, Consumption is 13 Kilometers is 340, Age is 140, Petrol price is 22 Average kilometers per day is: 2.42857 kilometers Average petrol consumption per day is: 694.571 dirhams Brand is Honda, Model is Civic, Consumption is 11 Kilometers is 453, Age is 123, Petrol price is 21.25 Average kilometers per day is: 3.68293 kilometers Average petrol consumption per day is: 860.884 dirhams
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
