- Given The Following Two Programs Write The Output Of The Carvalue Class Public Class Car Private Int Modelyear Pr 1 (166.96 KiB) Viewed 36 times
Given the following two programs, write the output of the CarValue class. public class Car { } private int modelYear; pr
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Given the following two programs, write the output of the CarValue class. public class Car { } private int modelYear; pr
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();