Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

hey guys. i am working on java program which calculates taxes depend on their income. So customer inputs what is his/her status(unmarried, married so on)

hey guys. i am working on java program which calculates taxes depend on their income. So customer inputs what is his/her status(unmarried, married so on) and then income and tax is calcualted. i have done this program with if else statemnts before(i will attache this program also) however right now i am trying to use OBJECT ORIENTED THINKING. Basycly i have one class for FederalIncomeTax.java which contains all calculations constructions, methods and so on which is needed to calculate how much tax will be for certaing amount. and second program FederalIncomeTaxClient.java which contains mainc method. so i finished everythink with FederalIncomeTax.java and when i am running it does compiles but of course not runs becuase it does not have main method. However my problem is to conncet FederalIncomeTax.java with FederalIncomeTaxClient.java. This is first time when i am trying to use two class to run one program so i have toruble. right now i will copy code which i have so far for FederalIncomeTax.java and FederalIncomeTaxClient. (I will also attache tax calculation program which i did previusly just to give you idea how it suppost to work) (i am not sure so if i have any mistake in FederalIncomeTax.java please correct me)

Thank you

---------------------------------------------------------------------------------------------------------------------------------------------------------

previus example

import java.util.Scanner;

public class ComputeTax { public static void main(String[] args) { // Create a Scanner Scanner input = new Scanner(System.in);

// Prompt the user to enter filing status System.out.print( "(0-single filer, 1-married jointly or qualifying widow(er), " + " 2-married separately, 3-head of household) " + "Enter the filing status: "); int status = input.nextInt();

// Prompt the user to enter taxable income System.out.print("Enter the taxable income: "); double income = input.nextDouble();

// Compute tax double tax = 0;

if (status == 0) { // Compute tax for single filers if (income <= 8350) tax = income * 0.10; else if (income <= 33950) tax = 8350 * 0.10 + (income - 8350) * 0.15; else if (income <= 82250) tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (income - 33950) * 0.25; else if (income <= 171550) tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (income - 82250) * 0.28; else if (income <= 372950) tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + (income - 171550) * 0.33; else tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + (372950 - 171550) * 0.33 + (income - 372950) * 0.35; } else if (status == 1) { // Compute tax for married file jointly // Left as exercise } else if (status == 2) { // Compute tax for married separately // Left as exercise } else if (status == 3) { // Compute tax for head of household // Left as exercise } else { System.out.println("Error: invalid status"); System.exit(1); }

// Display the result System.out.println("Tax is " + (int)(tax * 100) / 100.0); } }

--------------------------------------------------------------------------------------------------------------------------------------------------------------

FederalIncomeTax.java

public class FederalIncomeTax { int Status; double Income; double Tax; java.util.Date federalIncomeTaxDate;

public FederalIncomeTax( int Status, double Income, double Tax) { this.Status = Status; this.Income = Income; this.Tax = Tax; }

public double getStatus() { // retunr status return Status; } public void setStatus (int Status){ //set an new status this.Status = Status; }

public double getIncome(){ //retunr income; return Income; } public void SetIncome (double Income){ //set a new icnome this.Income = Income; }

public double getTotalTax(){ if (Status == 0) { // Compute tax for single filers if (Income <= 8350) Tax = Income * 0.10; else if (Income <= 33950) Tax = 8350 * 0.10 + (Income - 8350) * 0.15; else if (Income <= 82250) Tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (Income - 33950) * 0.25; else if (Income <= 171550) Tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (Income - 82250) * 0.28; else if (Income <= 372950) Tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + (Income - 171550) * 0.33; else Tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + (372950 - 171550) * 0.33 + (Income - 372950) * 0.35; } else if (Status == 1) { // Compute tax for married file jointly // Left as exercise } else if (Status == 2) { // Compute tax for married separately // Left as exercise } else if (Status == 3) { // Compute tax for head of household // Left as exercise } else { System.out.println("Error: invalid status"); //System.exit(1); } return 0; //java ask me to add } public java.util.Date getFederalIncomeTaxDate(){ return federalIncomeTaxDate; } }

------------------------------------------------------------------------------------------------------------------------------------------------------

FederalIncomeTaxClient .java // main method

import java.util.Scanner;

public class FederalIncomeTaxClient { public static void main(String[] args){ Scanner input = new Scanner(System.in);

System.out.println("enter the status "); int Status = input.nextInt();

System.out.println("enter the icnome "); double Income= input.nextDouble(); //creater the object //federalIncomeTax federalIncomeTax1 = new federalIncomeTax (Status, Income);

//System.out.prinln( "total taxes are "+ federalIncomeTax. );

}

}

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

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

3540416641, 978-3540416647

More Books

Students also viewed these Databases questions

Question

Define centroid.

Answered: 1 week ago