U0 Assign Truck AP
U0 Assign Truck AP
Create a class called Truck in your Unit 0 Folder. The Truck class should contain the following:
● Four private fields: make (String), model (String), miles (int), value (double)
● A default constructor that creates a default Truck that is a Chevrolet (the make) Colorado (the model)
with 35 miles on it and a current value of $27,000.
● A constructor that takes four parameters, one for each of the fields.
● An accessor for each field.
● A modifier for the miles and value fields only.
● A public void method named driveToWork() that increases miles by 20 (the distance from your home to
work) and reduces the value by .05%.
● A public void method named demolish() that sets the value to 0.
● Do not add any other methods!!!
● Ask the user for the make, model, miles, and value of their current Truck.
● Create a new Truck object called oldTruck that puts this information into the constructor. This is the
Truck that the user wants to sell.
● Instantiate another Truck object called newTruck using the default constructor. This is the Truck that
the user wants to buy.
● Print out the make, model, miles, and value of each of the Trucks using the accessors from the Truck
class.
● Print out the amount the user will pay for the new Truck. You should subtract the value of the old Truck
from the new Truck value, as the user will be trading in the old Truck.
● However, the dealer decides not to salvage the old Truck, so you need to demolish it.
● Next, the user will drive to work and back home. You should not create another method for this, and
you should not change the driveToWork() from the instructions I originally gave you.
● Print out the make, model, miles, and value of each of the Trucks again using the accessors.
Turn in the java files only (or a web url if using an online IDE) in Canvas when you are done.