Given the following two programs, write the output of the CarValue class. public class Car { } private int modelYear; pr
Posted: Fri Jul 08, 2022 7:27 am
Given the following two programs, write the output of the CarValue class. public class Car { } private int modelYear; private double purchasePrice; public void setModel Year(int userYear){ model Year = userYear; } public int getModelYear() { return modelYear; } public void setPurchase Price(double userPrice){ purchase Price = userPrice; } public double getPurchasePrice() { return purchasePrice; } public void printInfo() { System.out.println("Car's information:"); System.out.println(" Model year: " + model Year); System.out.println(" Purchase price: $" + purchasePrice); } Put your answers in the answer area. public class CarValue { public static void main(String[] args) { Car myCar = new Car(); myCar.setModelYear(2018); myCar.setPurchase Price (30000); myCar.printlnfo(); Car anotherCar = new Car(); double price = myCar.getPurchase Price(); price = price* 1.2; anotherCar.setModel Year (2019); anotherCar.setPurchase Price (price); anotherCar.printlnfo();