Answered You can hire a professional tutor to get the answer.

QUESTION

Anyone can solve this java code????

Anyone can solve this java code???? That receive income tax and repeat the program till the user enter -1

Scanner read=new Scanner(System.in);

    int income;

    double tax;

    int flag=1;

   System.out.println("Enter the income:");

   income=read.nextInt();

  while(income<=0)

  {flag=0;

  }

   if(income<20000)

   {

     tax=0;

   System.out.printf("Tax for $"+income+ "is $"+tax);

   } 

   else if (income<30000)

   {

     tax=(income-20000)*0.02;

   System.out.printf("Tax for $"+income+ "is $"+tax);

   }

   else if (income<40000)

       {

     tax=200+(income-30000)*0.035;

     System.out.printf("Tax for $"+income+ "is $"+tax);

   }

   else if (income<80000)

   {

     tax=550+(income-40000)*0.07;

  System.out.printf("Tax for $"+income+ "is $"+tax);

  }

   else if (income<120000)

   {

     tax=3350+(income-80000)*0.115;

   System.out.printf("Tax for $"+income+ "is $"+tax);

   }

   else if (income<160000)

   {

     tax=7950+(income-120000)*0.15;

     System.out.printf("Tax for $"+income+ "is $"+tax);

   }

   else if (income<200000)

   {

     tax=13950+(income-160000)*0.17;

     System.out.printf("Tax for $"+income+ "is $"+tax);

   }

   else if (income<320000)

   {

     tax=20750+(income-20000)*0.18;

     System.out.printf("Tax for $"+income+ "is $"+tax);

   }

   else if (income<640000)

   {

     tax=42350+(income-320000)*0.2;

   System.out.println("Tax for %.2f $"+income+ "is $"+tax);

   }

   {

  System.out.println("Tax for %.2f $"+income+ "is" $"+tax");

   }

else

{

System.out.print("nEnter income again, (-1 to stop the program): $");

income = read.nextInt();

}

   System.out.println("End of program");

  }

}

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question