我是一个java菜鸟。我在主要方法中不断出错。请帮忙!我认为我没有以正确的方式调用这些方法。其他一切都应该正常工作。
import java.util.Scanner;
public class Assignment5 {
public static void main(String[] args) {
Scanner kbd = new Scanner(System.in);
inputName(kbd);
inputIncome(kbd);
inputMarried(kbd);
calculateThreshold();
incomeBelowThreshold();
incomeAboveThreshold();
taxBelowThreshold();
taxAboveThreshold();
totalTaxes();
displayResults();
}
public static String inputName (Scanner kbd) {
System.out.print("What is your name?");
String name = kbd.nextLine();
return name;
}
public static double inputIncome (Scanner kbd) {
System.out.print("What is your annual income?");
double userIncome = kbd.nextDouble();
return userIncome;
}
public static char inputMarried (Scanner kbd) {
System.out.print("Are you married? (y for yes, n for no)");
char married = kbd.next().charAt(0);
return married;
}
public static double calculateThreshold (char married) {
double incomeThreshold;
if (married == 'y') {
incomeThreshold = 80000;
} else {
incomeThreshold = 40000;
}
return incomeThreshold;
}
public static double incomeBelowThreshold (double userIncome , double incomeThreshold) {
double incomeBelowThreshold;
if (userIncome <= incomeThreshold) {
incomeBelowThreshold = incomeThreshold - userIncome;
} else {
incomeBelowThreshold = userIncome;
}
return incomeBelowThreshold;
}
public static double incomeAboveThreshold (double userIncome, double incomeThreshold) {
double incomeAboveThreshold;
if (userIncome >= incomeThreshold) {
incomeAboveThreshold = incomeThreshold - userIncome;
} else {
incomeAboveThreshold = 0;
}
return incomeAboveThreshold;
}
public static double taxBelowThreshold (double incomeBelowThreshold) {
double taxBelowThreshold;
taxBelowThreshold = incomeBelowThreshold * .25;
return taxBelowThreshold;
}
public static double taxAboveThreshold (double incomeAboveThreshold) {
double taxAboveThreshold;
taxAboveThreshold = incomeAboveThreshold *.35;
return taxAboveThreshold;
}
public static double totalTaxes (double taxBelowThreshold, double taxAboveThreshold) {
double totalTaxes;
totalTaxes = taxBelowThreshold + taxAboveThreshold;
return totalTaxes;
}
public static void displayResults (String Name, char married, double income, double totalTaxes) {
System.out.print("Name:" + Name);
String marriedStatus;
if (married == 'y') {
marriedStatus = "Married";
} else {
marriedStatus = "Single";
}
System.out.print("Marital Status:" + marriedStatus);
System.out.printf("Income: %.2f" + income);
System.out.printf("Taxes: %.2f" + totalTaxes);
}
}