Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Someone please answer this me ASAP thank you so much in advance. For this Assignment, you will write the following program: Create an Automobile class

Someone please answer this me ASAP thank you so much in advance.

For this Assignment, you will write the following program:

Create an Automobile class for a dealership to keep the auto inventory current. Include fields for an ID number, model, color, year, and miles per gallon. Include get and set methods for each field.

In the set methods, code the values validations as follows:

Do not allow the ID to be negative or more than 9999. If it is, set the ID to 0.

Do not allow the year to be earlier than 2005 or later than 2021. If it is, set the year to 0.

Do not allow the miles per gallon to be less than 10 and more than 60. If it is, set the miles per gallon to 0.

Include a constructor that accepts arguments for each field and assign their values to the parameters passed (call the set methods for each field within that constructor).

Write the application driver class TestAutomobiles, which has three methods:

createAutomobile() method, which is the void method (will not accept any parameters), but will create and return the Automobile object with the fields to be set from the users inputs. Within this method: first, create an object of the Automobile class making use of the Automobile class constructor and pass to that constructor the user inputs for each object field. You might accept the user inputs first and store the data in proper variables. Include the proper prompts for a user to enter data for each field. Then, when the users data is stored in the proper variables - call Automobile constructor passing the input data values to the Automobile object being created.

Utilize the Scanner or JOptionPane class to accept user input.

The void displayAutomobile(Automobile newAutomobile) method, which will accept an Automobile object as a parameter, calls the get methods of that object to determine each field value and displays these fields values. You can use command line interface or JOptionPane to display the fields values.

The main () method

Here you will create two Automobile objects, one after another, by calling the createAutomobile() method twice. Each time you call the createAutomombile() method and that method will be processed with user inputs asked for and provided for each Automobile object fields. Then the Automobile object with these fields values will be created. That object will be returned to the main method for display.

After these two Automobile objects are created - call displayAutomobile(Automobile oneAutomobile) twice, once for each of the two Automobile objects created, and display each of two automobile field values.

Make your application user-friendly. When the application starts, display a welcome message explaining what a user will be doing next in this application.

In the main method, you may also declare and use the StringBuilder class to accumulate and format the final output of the application in a table of two Automobile objects (this is optional for a higher grade).

Zip Automobile. java, TestAutomobiles.java, and an MS Word .doc with the screenshots of the running application (including a detailed explanation of your solution) into a single .zip archive named WK5Assgn+last name+first initial.zip.

Submit the WK5Assgn+last name+first initial.zip for grading no later than the due date for this deliverable.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions