Question: JAVA LANGUAGE Use your Car class and create a new class that represents a Used Car. Your program will simulate a listing system for the

JAVA LANGUAGE

Use your Car class and create a new class that represents a "Used Car". Your program will simulate a listing system for the business, where the staff will manage the car information. Start by creating an array of 5 cars, with an "ID" of 0 through 4, and use the default constructor to create each car. For instance, the fifth car in an array called cars would have ID 4. You would access it by using:

cars[4]

To display this car's information, you would use:

cars[4].toString();

Use a loop to assist you initialize each car.

The system ought to first prompt the user for an ID, and ensure that it's valid from 0 through 4. Once the id is accepted, the menu ought to be displayed as follows:

JAVA LANGUAGE Use your Car class and create a new class that Set Make - Get the new Make from the user, and set it to the present car's Make field

represents a "Used Car". Your program will simulate a listing system for Set Model - Get the new Model from the user, and set it to the present car's Model field

the business, where the staff will manage the car information. Start by Set Year - Get the new Year from the user, and set it to the present car's Year field

creating an array of 5 cars, with an "ID" of 0 through Set Cost - Get the new Cost from the user, and set it to the present car's Cost field

4, and use the default constructor to create each car. For instance, Set Color - Get the new Color from the user, and set it to the present car's Color field

the fifth car in an array called cars would have ID 4. Show Car Information

You would access it by using: cars[4] To display this car's information, Exit, and opt for new car ID

Any other menu option, a message will appear as invalid. Your program should run continuously. The "Exit" option can prompt the user to pick a new ID and start entering/displaying information for a distinct car.

*****MY CAR CLASS*****

public class Car {

public static void main(String[] args) {

Car1 car1 = new Car1();

car1.setCar(Car1.DODGE);

car1.setMake("Dodge");

car1.setModel("Durango");

car1.setYear(car1.getYear());

car1.setCost(40000);

car1.setColor(car1.getColor());

System.out.println(car1.toString());

System.out.println();

Car1 car2 = new Car1 ();

//Car 2 setters

car2.setCar(Car1.CHEVY);

car2.setMake("Chevy");

car2.setModel("Tahoe");

car2.setYear(car2.getYear());

car2.setCost(45000);

car2.setColor("Black");

System.out.println(car2.toString());

}

}

class Car1 {

public static final int DODGE = 1;

public static final int CHEVY = 2;

private int car = DODGE;

//the default is "Make"

private String make = "Make";

//the default is "Model"

private String model = "Model";

//the default is 2019

private int year = 2019;

//the default is 50,000

private double cost = 50000;

//the default is "Silver"

private String color = "Silver";

public int getCar() {

return car;

}

public void setCar(int car) {

this.car = car;

}

public String getMake() {

return make;

}

public void setMake(String make) {

this.make = make;

}

public String getModel() {

return model;

}

public void setModel(String model) {

this.model = model;

}

public int getYear() {

return year;

}

public void setYear(int year) {

this.year = year;

}

public double getCost() {

return cost;

}

public void setCost(double cost) {

this.cost = cost;

}

public String getColor() {

return color;

}

public void setColor(String color) {

this.color = color;

}

public String toString() {

return "Car " + car + " Make: " + make + " Model: " + model + " Year: " + year + " Cost: $" + cost + " Color: " + color;

}

}

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!