Question: Can you explain what the lines of code for both classes do? I understand the basic stuff like the import, main method, and what the

Can you explain what the lines of code for both classes do?I understand the basic stuff like the import, main method, and whatCan you explain what the lines of code for both classes do? I understand the basic stuff like the import, main method, and what the print statements do. But I am mainly confused on why line 8 is Car myCar = new Car() what is it doing? How do the setters and getters work? And how do lines 14 - 16 work for the carValue class? I want to know how these to classes work with eachother.

File is marked as read only Current file: CarValue.java 1 Import java.util.Scanner; import java.lang. Math; 4 public class CarValue { 5 public static void main(String[] args) { 6 Scanner scnr = new Scanner(System.in); 7 8 Car myCar = new Car(); 9 10 int userYear = scnr.nextInt(); 11 int userPrice = scnr.nextInt(); 12 int userCurrentYear = scnr.nextInt(); 13 14 myCar.setModelYear(userYear); 15 myCar.setPurchasePrice(userPrice); 16 myCar.calcCurrentValue( userCurrentYear); 17 18 myCar.printInfo(); 19 + 20 > 21 Develop mode Submit mode Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box. Enter program input (optional) 2011 18000 2018 Current file: Car.java Load default template... 1 public class Car 2 private int modelYear; 3 int purchasePrice; 4 int currentValue; 5 6 public void setModelYear(int userYear) { 7 modelYear = userYear; 8 } 9 10 public int getModel Year() { 11 return model Year; 12 } 13 14 public void setPurchasePrice(int purchasePrice) { 15 this.purchasePrice = purchasePrice; 16 } 17 18 public int getPurchasePrice) { 19 return purchasePrice; 20 } 21 22 public void calcCurrentValue(int currentYear) { 23 double depreciation Rate = 0.15; 24 int carAge = currentYear - modelYear; 25 26 // Car depreciation formula 27 currentValue = (int) 28 Math.round(purchasePrice * Math.pow((1 - depreciationRate), carAge)); 29 } 30 31 public void printInfo() { 32 System.out.println("Car's information:"); 33 System.out.println(" Model year: " + model Year); 34 System.out.println(" Purchase price: " + purchasePrice); 35 System.out.println(" Current value: " + currentValue); 36 } 37 } Du Vour arcaram aftan Vou'd liza bafara submitting for aradina Dalamunaw ngadad

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!