Question: 3 3 . 2 4 LAB: Car value ( classes ) Given main ( ) , complete the car class ( in file Car.java )

33.24 LAB: Car value (classes)
Given main(), complete the car class (in file Car.java) with methods to set and get the purchase price of a car (setPurchasePrice(),
getPurchasePrice(), and to output the car's information (printlnfo()).
Ex: If the input is:
2011
18000
2018
where 2011 is the car's model year, 18000 is the purchase price, and 2018 is the current year, the output is:
Car's information:
Model year: 2011
Purchase price: $18000
Current value: $5770
Note: printinfo() should use two spaces for indentation.
File is marked as read only
public static void main(String[] args){
Scanner scnr = new Scanner(
System.in);
Car myCar = new Car();
int useryear = scnr. nextInt();
int userPrice = scnr.nextInt();
int userCurrentYear = scnr.nextInt();
myCar.setModelYear(userYear);
myCar.setPurchasePrice(userPrice);
mycar.calcCurrentValue(userCurrentYear);
myCar.printInfo();
}
}
3 3 . 2 4 LAB: Car value ( classes ) Given main (

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 Programming Questions!