subject

Need asap. i need an example of how to do this right.

the second programming project involves writing a program that computes the sales tax for a collection of automobiles of different types. this program consists of four classes. the first class is the automobile class, which contains the automobile’s make and model, and purchase price, which is specified in whole dollars. it should have three methods:

1. a constructor that allows the make and purchase price to be initialized.

2. a method named salestax that returns the base sales tax computed as 5% of the sales price.

3. a tostring method that returns a string containing the make and model of the automobile, the sales price, and the sales tax, appropriately labeled.

the automobile class has two subclasses. the first is electric. it has an additional instance variable that contains its weight in pounds stored as an integer. it should have the same three methods:

1. a constructor that allows the automobile’s make and model, purchase price and weight to be initialized.

2. an overridden method salestax that returns the total sales tax. the sales tax for an electric automobile consists of the base sales tax of 5% that applies to all automobiles minus a discount. if the weight is less than 3000 pounds the discount is $200. otherwise it is $150.

3. an overridden tostring method that returns a string containing the make and model of the automobile, the sales price, sales tax and the weight, appropriately labeled.

the second subclass is hybrid. it has an additional instance variable that contains the number of miles per gallon stored as an integer. it should have the same three methods:

1. a constructor that allows the automobile’s make and model, purchase price and miles per gallon to be initialized.

2. an overridden method salestax that returns the total sales tax the sales tax for a hybrid automobile consists of the base sales tax of 5% minus a discount. if the number of miles per gallon is less than 40, the discount is $100. otherwise there is an additional discount of $2 for every mile per gallon in excess of 40.

3. an overridden tostring method that returns a string containing the make and model of the automobile, the sales price, sales tax and the number of miles per gallon, appropriately labeled.

no additional public methods should be included in any of the above three classes.

finally there should be a fourth class named project2 that contains the main method. it should generate the gui shown below:

after entering the information about the make and model, its sales price and the type of the automobile, clicking the compute sales tax button should display the sales tax in the text field to its right. in addition, the object should be stored in an array of type automobile.

that array should allow space for up to the last five automobiles entered.
if non integer values are entering in any of the fields that require integers, an error message should be displayed in a joptionpane window.
clicking the clear fields button should clear all text fields.

clicking the display report button should produce a report on the console that includes the information about all the automobiles currently stored in the array. an example of the report that should be displayed is shown below:

make and model: toyota prius sales price: 3 sales tax: 1390.00 hybrid vehicle mpg: 45

make and model: ford fusion sales price: 21000 sales tax: 1050.00

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 17:30, kallee10
The forerunner to cell phones, pdas, and smartphones was
Answers: 1
image
Computers and Technology, 22.06.2019 22:30, studybug2306
Jason needs to learn a new web tool. he went through his books to understand more about it. now he wants hands-on experience with using that tool. what would him? jason can use websites where workspace is provided to test the results of your code.
Answers: 2
image
Computers and Technology, 23.06.2019 15:00, puppylove899
Barbara is interested in pursuing a career in the science and math pathway. which qualifications will her reach that goal? a. an advanced knowledge of physics and math b. an advanced knowledge of engineering and math c. an advanced knowledge of physics and robotics an d. advanced knowledge of machinery and math
Answers: 1
image
Computers and Technology, 24.06.2019 05:50, 11232003
What all vehicles has tesla inc. created over the years
Answers: 3
You know the right answer?
Need asap. i need an example of how to do this right.

the second programming project in...

Questions in other subjects: