4 Replies - 210 Views - Last Post: 06 April 2019 - 06:18 AM Rate Topic: -----

#1 CHiFONG   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 05-April 19

Proble with Income Tax calculate

Posted 05 April 2019 - 09:10 PM

Hi I was the beginner for Java the assignment ask me to calculate the income tax.
How can I total up the tax T.T.

The display output is

Enter the income:$ 450000
Tax for $45000.00 is $900.00

Thank you for helping me T.T!!!



import java.text.NumberFormat;
import java.util.Scanner;
public class Q3B
{
public static void main(String[] args)
{

//Enter Income
Scanner input = new Scanner(System.in);
double netIncome, tax, twoPercentTax, tenPercentTax;
System.out.print("Enter the income");
double income = in.nextDouble();
NumberFormat format = NumberFormat.getCurrencyInstance();




if (income >0 && income <=20000)
tax = 0;
else if (income >20000&& income<= 30000)
tax = 0+(0.02*(income - 20000));
else if (income >30000&& income<= 40000)
tax = 200+(0.035*(income - 30000));
else if (income >40000&& income<= 80000)
tax = 550+(0.07*(income - 40000));
else if (income >80000&& income<= 120000)
tax = 3350+(0.115*(income - 80000));
else if (income >120000&& income<= 160000)
tax = 7950+(0.15*(income - 120000));
else if (income >160000&& income<= 200000)
tax = 13950+(0.17*(income - 160000));
else if (income >200000&& income<= 320000)
tax = 20750+(0.18*(income - 200000));
else if (income > 320000)
tax = 42350+(0.20*(income - 320000));
else if (income >0 && income <=0);

if (income >0 && income <=20000)
{
System.out.println("Tax for $"+format.format(income)+" is "0+(tax *)+".");
}


}
}

Is This A Good Question/Topic? 0
  • +

Replies To: Proble with Income Tax calculate

#2 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3623
  • View blog
  • Posts: 16,656
  • Joined: 20-September 08

Re: Proble with Income Tax calculate

Posted 06 April 2019 - 03:36 AM

Please use code tags as you were asked. andrewsw's Posted Image instructions will show you how to use code-tags. It isn't difficult.
EACH JAVA FILE should have its own code tags

http://technojeeves....java1/17-errors
Was This Post Helpful? 0
  • +
  • -

#3 NormR   User is offline

  • D.I.C Lover
  • member icon

Reputation: 765
  • View blog
  • Posts: 5,767
  • Joined: 25-December 13

Re: Proble with Income Tax calculate

Posted 06 April 2019 - 03:50 AM

Quote

How can I total up the tax T.T.

Can you post the desired output?
Was This Post Helpful? 0
  • +
  • -

#4 CHiFONG   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 05-April 19

Re: Proble with Income Tax calculate

Posted 06 April 2019 - 06:02 AM

Hi guy the problem for this is the output support to I enter the income and it show the tax for $ is $.
The thing is I need to type two time for my income it only were show the tax payment. Another is after show the tax, when I need to type second time for my income, need to repeat two times.

Thank you please help

The Output is look like this

Enter the income :45000
Tax for $45000.00 is $900
Enter income again. (-1 to stop the program) :



import java.text.NumberFormat;
import java.util.Scanner; 
public class Prog1 
{

    public static void main(String[] args)
    {
      
        Scanner keyboard = new Scanner (System.in);
        int num;
        Scanner input = new Scanner(System.in);
        System.out.print("Enter the income : ");
        num = keyboard.nextInt(); 
        double income = input.nextDouble();
        NumberFormat format = NumberFormat.getCurrencyInstance();
      
        while (num != -1)
        {

        if (income >0 && income <=20000)
        {
          System.out.println("Tax for $"+format.format(income)+" is 0.");
        }
        else if (income >20000&& income<= 30000)
        {
           System.out.println("Tax for $"+format.format(income)+" is "+format.format ((income-20000)*0.02)+".");
        }
        else if (income >30000&& income<= 40000)  
        {
           System.out.println("Tax for $"+format.format(income)+" is "+format.format(200+(income-30000)*0.035)+"."); 
        } 
        else if (income >40000&& income<= 80000)
        {
           System.out.println("Tax for $"+format.format(income)+" is "+format.format(550+(income-40000)*0.07)+".");  
        } 
        else if (income >80000&& income<= 120000)
        {
            System.out.println("Tax for $"+format.format(income)+" is "+format.format(3350+(income-80000)*0.115)+".");  
        } 
        else if (income >120000&& income<= 160000)
        {
           System.out.println("Tax for $"+format.format(income)+" is "+format.format(7590+(income-120000)*0.15)+".");   
        }    
        else if (income >160000&& income<= 200000)
        {
           System.out.println("Tax for $"+format.format(income)+" is "+format.format(13950+(income-160000)*0.17)+".");   
        }
        else if (income >200000&& income<= 320000)
        {
            System.out.println("Tax for $"+format.format(income)+" is "+format.format(20750+(income-200000*0.18))+".");   
        }
        else if (income > 320000)
        {
            System.out.println("Tax for $"+format.format(income)+" is "+format.format(42350+(income-320000)*0.20)+".");  

        }
             System.out.print("Enter income again,(-1 to stop the program\n");
               num = keyboard.nextInt();
      }        
        
        
        
        
    }
}






Was This Post Helpful? 0
  • +
  • -

#5 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3623
  • View blog
  • Posts: 16,656
  • Joined: 20-September 08

Re: Proble with Income Tax calculate

Posted 06 April 2019 - 06:18 AM

while (income >= 0) {


could be used to do what you want. Read that value only
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1