Jump to content

Recommended Posts

Guest JaznerPajarin
Posted

https://extremetechsupport.com/data/MetaMirrorCache/99d277a0ccd55f1adc57ee931bf453f5._.jpg

 

THIS IS MY ASS1B CODES AND I HAVE TO ACCOMPLISH THE TASK GIVEN IN THE IMAGE BY USING LOOPS

 

N = 3(FOR TESTING ONLY)

 

I MUST GET THE AVERAGE OF THE TOTAL TAX IN EVERY PERSON BY USING ONLY 1 SCANNER FOR INCOME.

 

import java.util.Scanner;

public class Ass1c

{

public static void main (String[]args)

{

 

String taxPayerName;

int totalInc;

double totalTax;

int x = 0;

 

 

Scanner inText = new Scanner(System.in);

System.out.print("Please enter the name of the tax payer==> ");

taxPayerName = inText.nextLine();

 

Scanner inNumber = new Scanner(System.in);

System.out.println("Enter the income for "+ taxPayerName +" ==> " );

totalInc = inNumber.nextInt();

if (totalInc < 18200)

{

totalTax = 0;

System.out.print("The tax that " + taxPayerName + " has to pay is $"+ totalTax);

}

else if(totalInc < 37000)

{

totalTax=((totalInc - 18200)* 0.19);

System.out.print("The tax that " + taxPayerName + " has to pay is $"+ totalTax);

}

else if(totalInc < 87000)

{

totalTax=(3572 +(totalInc - 37000)* 0.325);

System.out.print("The tax that " + taxPayerName + " has to pay is $"+ totalTax);

}

else if(totalInc < 180000)

{

totalTax=(19822 +(totalInc - 87000)* 0.37);

System.out.print("The tax that " + taxPayerName + " has to pay is $"+ totalTax);

}

else

{

totalTax = (54232 + (totalInc - 180000)*0.47);

System.out.print("The tax that " + taxPayerName + " has to pay is $"+ totalTax);

}

 

}

}

 

Continue reading...

  • Replies 0
  • Created
  • Last Reply

Popular Days

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...