프로그램에 세금이 부과되기 전에 소득을 두 번 입력해야 함 & 다른 세금 브래킷을 계산할 때 하나의 세금 브래킷 (10 %) 만 사용합니다. . 아래 코드는 다음과 같습니다.내 세금 계산기 프로그램이 거의 완료되었지만 몇 가지 문제가 있음
package org.tax.tutorial;
import java.util.Scanner;
public class Taxability {
//The main method of this program
public static void main(String[] args){
int userInput = 0;
double bracketOne = 0.10;
double bracketTwo = 0.15;
double bracketThree = 0.25;
double bracketFour = 0.28;
double bracketFive = 0.33;
double bracketSix = 0.35;
double total = 0.0;
//Inform user about the program
System.out.println("This program is designed to calcualte your annual income and determine how much taxes you currently owe." + "\n");
//Inform user about tax brackets
System.out.print("Based on your income you may be classifed under one of the six brackets:" + "\n" + "\n" + "Bracket 1: 0–$8,500 10%" + "\n" + "Bracket 2: $34,500 15%" + "\n" + "Bracket 3: $34,500–$83,600 25%" + "\n" + "Bracket 4: $83,600–$174,400 28%" + "\n" + "Bracket 5: $174,400–$379,150 33%" + "\n" + "Bracket 6: $379,150 above 35%" + "\n" + "\n");
{
//User inputs their annual income
System.out.println("Please submit your annual income for the following year 2013-2014:");
//Create a Scanner object for keyboard input
@SuppressWarnings("resource")
Scanner keyboard = new Scanner(System.in);
userInput = keyboard.nextInt();
if ((userInput >= 0) & (userInput<= 8500));{
total = bracketOne * keyboard.nextDouble();
System.out.println("Total tax owed is $" + total + "\n" + "\n" + "Thank your for using the tax calculator.");
}
if ((userInput >=8500) & (userInput <= 34500));{
total = bracketTwo * keyboard.nextDouble();
System.out.println("Total tax owed is $" + total + "\n" + "\n" + "Thank your for using the tax calculator.");
}
if ((userInput >=34500) & (userInput <= 83600));{
total = bracketThree * keyboard.nextDouble();
System.out.println("Total tax owed is $" + total + "\n" + "\n" + "Thank your for using the tax calculator.");
System.exit(0);
}
if ((userInput >=83600) & (userInput <= 174400));{
total = bracketFour * keyboard.nextDouble();
System.out.println("Total tax owed is $" + total + "\n" + "\n" + "Thank your for using the tax calculator.");
}
if ((userInput >=174400) & (userInput <= 379150));{
total = bracketFive * keyboard.nextDouble();
System.out.println("Total tax owed is $" + total + "\n" + "\n" + "Thank your for using the tax calculator.");
}
if (userInput >=379150);{
total = bracketSix * keyboard.nextDouble();
System.out.println("Total tax owed is $" + total + "\n" + "\n" + "Thank your for using the tax calculator.");
System.exit(0);
}
}
}
}
이 사이트는 질문 할 때 더 잘 작동합니다. –
0-379,150의 숫자 중에서 무작위로 선택하십시오. 이 프로그램은 첫 번째 세금 괄호 (10 %)에 대해 정확하게 계산을 수행하지만 8,500 이후의 항목은 빚진 세금에 대해 동일한 비율을 사용합니다. – brittneyjava
그리고 프로그램이 계산을 실행하기 전에 숫자를 두 번 입력해야합니다. – brittneyjava