Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

must be in java Computing Taxes program. This is the problem 5.2 on page 228 of your text. Create a class named TaxCalculator Do not

must be in java

Computing Taxes program. This is the problem 5.2 on page 228 of your text.

Create a class named TaxCalculator

Do not create instance variables or a constructor.

Create a method named calculateTax and it should return a double. It should have two arguments. One argument will be String named maritalStatus. The other argument should be a double named taxableIncome.

You will need nested if statements. The outside test should be whether maritalStatus is equal to married. Remember this is a String and you should use String comparison. An example of the if else statement is on page 200. An example of the String comparison is on page 186 and you need to use the .equals. Inside the comparison you need another set of if statements for the levels of taxableIncome. You will need to use a compound if statement to compare the various income levels. See top of page 212. Return the income tax due as a double.

Create a TaxCalculatorTester

Import Scanner

Create a Scanner object

Prompt the user for their marital status and assign it to a String.

Prompt the user for their income and assign it to a double.

Create an object of type TaxCalculator;

Create a taxDue double variable

Call the calculateTax method and assign the output to taxDue.

Print the martial status with appropriate words Marital Status is: XXX

Print the income with appropriate words.

Print the totalIncome with appropriate words.

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

More Books

Students also viewed these Databases questions