Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java// please use the code provided!! I attached a photo. Thank you. 7.24 LAB: Car value (classes) Given main . complete the Car class (in
Java// please use the code provided!! I attached a photo. Thank you.
7.24 LAB: Car value (classes) Given main . complete the Car class (in file Carjava) with methods to set and get the purchase price of a car (setPurchasePricee. getPurchasePrice0), and to output the car's information (printinfo0). Exif the ingut is: 2011180002018 Where 2017 is the car's model year, 18000 is the purchase price, and 2018 is the current yeac, the output is: Carts information: Model year: 2011 Purchase pricet $18000 Curtent value: $5770 Note printinfo0 should use two spaces for indentation. File is marked as read only. Current fule: CarValue.j public class Car \{t private int modelyear; II TOD0: Declare purchasePrice field (int) private int currentValue; public void setModelYear(int userYear) \{ modelYear = userYear; \} public int getModelYear( \& return modelYear; 3 1/ TOOO: Define setPurchaseprice() method 1/ TODO: Define getPurchasePrice() method public void calcCurrentValue(int currentYear) \{ double depreciationRate =0.15; int carAge - currentYear - modelYear; 1/ Car depreciation formula currentValue = (int) Math. round(purchasePrice * Math. pow((1 - depreciationRate), carAge)); 3 1/ TODO: Define printInfo() method to output modelYear, purchaseprice, and currentValue Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started