value = 20,000 - (1,000 * age) Sample Execution 1 Enter the VIN for the vehicle: ABC123 How old is the vehicle (in years): 4 Has the vehicle been in an accident? Y How much damage was incurred to the vehicle (in dollars)? 15500 The value for vehicle ABC123 is $500.00 due to excessive damages Sample Execution 2 Enter the VIN for the vehicle: ABC123 How old is the vehicle (in years): 4 Has the vehicle been in an accident? N The value for vehicle ABC123 is $16,000.00
The two pictures uploaded are explaining the task
![Background
When you are buying a new car something you can do to reduce the cost that you are paying is trade-in
your current vehicle. The dealer appraises your car and offers you some amount of money towards the
new car you are purchasing. Multiple factors determine this trade-in value including the age of the
vehicle and whether or not the vehicle has been in an accident. If the vehicle has been in an accident that
resulted in the vehicle incurring more than $15,000 in damage the vehicle is considered to be a
"reconstructed vehicle" and the trade in value is only $500.
Objectives
By completing this lab students should be able to:
●
Write programs using functions
Implementation
Write a program called appraisal.cpp. The program will have the following functions:
• getVIN (): Gets the VIN number for the vehicle from the user and returns the value as a string.
getVehicleAge (): Gets the age of the vehicle in years and returns this value as an int.
askForAccidents (): Asks the user if the vehicle has been in an accident or not and returns the
result as a char.
computeValue(int age, char accidents, string vin): Computes the value of the
trade in and prints the result to the screen. If the vehicle has been in an accident it will ask for the
amount of damage incurred. If the damage is over $15,000 the car will only be worth $500.
Otherwise the value can be computed using the following equation:](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F786f2434-f93b-4d75-94ac-11c16e74081a%2Fe5799463-41cf-4f85-a46b-e7d7afdcd4ec%2Fol4rg5h_processed.png&w=3840&q=75)
![value =
20,000 (1,000 * age)
Sample Execution 1
Enter the VIN for the vehicle: ABC123
How old is the vehicle (in years): 4
Has the vehicle been in an accident? Y
How much damage was incurred to the vehicle (in dollars)? 15500
The value for vehicle ABC123 is $500.00 due to excessive damages
Sample Execution 2
Enter the VIN for the vehicle: ABC123
How old is the vehicle (in years): 4
Has the vehicle been in an accident? N
The value for vehicle ABC123 is $16,000.00](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F786f2434-f93b-4d75-94ac-11c16e74081a%2Fe5799463-41cf-4f85-a46b-e7d7afdcd4ec%2Fqw1gyoh_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Algorithm of the code:
1. Create a function called getVIN that takes no parameters and returns a string
2. Create a function called getVehicleAge that takes no parameters and returns an integer
3. Create a function called askForAccidents that takes no parameters and returns a character
4. Create a function called computeValue that takes three parameters (an integer, a character, and a string) and returns no value
5. In the main function, call the getVIN function and store the returned value in a string variable
6. Call the getVehicleAge function and store the returned value in an integer variable
7. Call the askForAccidents function and store the returned value in a character variable
8. Call the computeValue function, passing in the integer, character, and string variables as parameters
9. If the character variable is 'Y', prompt the user for an integer and store it in a new integer variable
10. If the integer from step 9 is greater than 15000, print that the value for the vehicle is $500.00 due to excessive damages
11. If the integer from step 9 is not greater than 15000, calculate the value of the vehicle as 20000 - (1000 * age) and print the value
12. If the character variable is not 'Y', calculate the value of the vehicle as 20000 - (1000 * age) and print the value
13. End the program
Step by step
Solved in 4 steps with 4 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)