-4
1つの変数を使用してスキャナから3つの入力を追加するにはどうすればいいですか?&はループのみ(配列なし)ですか? CLICK THIS LINK TO SEE IMAGE INCLUDING INSTRUCTIONSforループとwhileループ
ここでは、画像にタスクを完了するためのコードが必要です。
import java.util.Scanner;
public class Ass1b
{
public static void main (String[]args)
{
String taxPayerName;
int totalInc;
double totalTax;
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.print("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);
}
}
}