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

Principles of Information Systems (MindTap Course List)
12th Edition
ISBN:9781285867168
Author:Ralph Stair, George Reynolds
Publisher:Ralph Stair, George Reynolds
Chapter11: Knowledge Management And Specialized Information Systems
Section: Chapter Questions
Problem 2CTQ2
icon
Related questions
Question
100%

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:
Transcribed Image Text: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:
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
Transcribed Image Text: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
Expert Solution
Step 1

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

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Random access
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Principles of Information Systems (MindTap Course…
Principles of Information Systems (MindTap Course…
Computer Science
ISBN:
9781285867168
Author:
Ralph Stair, George Reynolds
Publisher:
Cengage Learning
Principles of Information Systems (MindTap Course…
Principles of Information Systems (MindTap Course…
Computer Science
ISBN:
9781305971776
Author:
Ralph Stair, George Reynolds
Publisher:
Cengage Learning