Question: Java programming - Use the JOptionPane.showing InputDialog ( ) method instead of scanner class Create an Automobile class for a dealership. Include fields for an
Java programming Use the JOptionPane.showing InputDialog method instead of scanner class
Create an Automobile class for a dealership. Include fields for an ID number, make, model, color, year, and miles per gallon. Include get and set methods for each field. Do not allow the ID to be negative or more than ; if it is set the ID to Do not allow the year to be earlier than or later than ; if it is set the year to Do not allow the miles per gallon to be less than or more than ; if it is set the miles per gallon to Include a constructor that accepts arguments for each field value and uses the set methods to assign the values.Given code:public class Automobile private int id; private String make; private String model; private String color; private int year; private double mpg; public Automobileint id String make, String model, String color, int year, double mpg public void setIdint id public void setMakeString make public void setModelString model public void setColorString color public void setYearint yr public void setMpgdouble mpg public int getId public String getMake public String getModel public String getColor public int getYear public double getMpgpublic class TestAutomobiles public static void mainString args Automobile auto new Automobile "Chevrolet", "Camaro", "red", ; Automobile auto new Automobile "Ford", "Focus", "white", ; displayauto "good declaration"; displayauto "bad declaration"; autosetId; displayauto "bad ID; autosetId; displayauto "good ID; autosetMakeToyota; autosetModelCorolla; displayauto "change make and model"; autosetId; autosetColorblue; autosetYear; displayauto "change ID color, and year"; autosetMpg; displayauto "bad mpg; autosetMpg; displayauto "good mpg; public static void displayAutomobile auto, String msg System.out.printlnmsg auto.getId auto.getMake auto.getModel auto.getColor auto.getYear auto.getMpg miles per gallon";
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
