Question: Write a java program that creates a class Car . Class Car contains the following private member fields: make, model, year, and miles. The class

Write a java program that creates a class Car. Class Car contains the following private member fields: make, model, year, and miles. The class Car has a constructor that takes as arguments the car make, model, and year. In addition, the constructor sets miles to 100 as default. Class Car has accessors and mutators to get and set the make, model, year and miles on the car. The program should complete the following tasks:

  1. Ask the user to enter make, model, and year for a car creating an object.
  2. Display back the make, model, year, and default miles for the car using accessor methods.
  3. Ask the user to enter the new miles (e.g. 50,000).
  4. Display the new miles using accessor method.

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!