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

Write a C++ program to do the following: 1. Enter the following car information

ID: 3749980 • Letter: W

Question

Write a C++ program to do the following: 1. Enter the following car information Model . Year . Price Had an accident (Y:Yes N:No)? 2. Find the car price after 20% discount 3. If the price less than or equal 1500 and the car has no accident display "Decision: Good Deal" else display "Decision: Expensive". 4. Display the car information as shown in figure below CAUsers sxanw Documents)Untitled1.exe CAR REPAIR SHOP Enter Car Information Enter Car Model Totota Camry Enter Car Year: 203 Enter Car Price: 2100.99 Had an accident (Yes:Y No:N)? n Find price after 20% discount Price after 20 % discount is: 1688.79 Decision: Expensive Car Information Model Totota Camry Year: 2003 Price after 20% discount: 1680.79 Had an accident? No Press any key to continue .. .

Explanation / Answer

#include <cstdlib>
#include <string>
#include<iostream>
using namespace std;

//holds car information
class Car {
private:
//instance variables
string model;
int year;
double price;
bool accident;
public:
//constructor   

Car(string m, int y, double p, char a) {
model = m;
year = y;
price = p;
if (a == 'n')
accident = false;
else
accident = true;
}

//getters   

string getAccident() const {
if (accident)
return "Yes";
else
return "No";
}

//prints the car information   

void print() {
cout << " Car Information";
cout << " Model:" << model;
cout << " Year :" << year;
cout << " Price after 20% discount:" << price-(price * 0.20);
cout << " Had an accident?" << getAccident();
}


};

/*
*
*/
int main(int argc, char** argv) {
string m;
double p;
int year;
char a;
double pDiscount;

cout << " CAR REPAIR SHOP ";
cout << " Enter Car Information ";
cout << "Enter Car Model:";
getline(cin,m);
cout << "Enter Car Year:";
cin>>year;
cout << "Enter Car Price:";
cin>>p;
cin.get(a);
cout << "Had an accident?(y:yes n:no):";
cin.get(a);
Car car(m, year, p, a);
cout << " ********************************************************************";
cout << " Find price after 20% discount";
pDiscount = p-(p * 0.20);//price after discount
cout << " Price after 20% discount is:" << pDiscount;
if (pDiscount <= 1500 && a == 'n')
cout << " Good Deal";
else
cout << " Decision:Expensive";
cout << " ********************************************************************";
car.print();
cout << " Press any key to continue.... ";
cin.get(a);
}

Sample Output

CAR REPAIR SHOP

Enter Car Information
Enter Car Model:Toyota Camry
Enter Car Year:2003
Enter Car Price:2100.99
Had an accident?(y:yes n:no):n

********************************************************************
Find price after 20% discount
Price after 20% discount is:1680.79
Decision:Expensive
********************************************************************
Car Information
Model:Toyota Camry
Year :2003
Price after 20% discount:1680.79
Had an accident?No
Press any key to continue....

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