我为此代码获得的错误:类型是非法的开始。
我无法确定在下面的代码中放置括号的位置:
import java.util.Scanner; public class TaxCalculator {
public static void main(String [] args)
{
Scanner keyboard = new Scanner(System.in);
System.out.println("What is your income?");
double income; //Income
income = keyboard.nextDouble();
System.out.println("How many dependents are in your household?");
int dependents; //Dependents
dependents = keyboard.nextInt();
}
public static void sd();
int singleyes = 5950;
int singleno = 11900;
boolean single = true;
if (single = yes)
StandardDeduction = 'yes';
} else if (single = no) {
StandardDeduction = 'no'; }
答案 0 :(得分:1)
您的sd
方法声明不正确。布尔值永远不会是yes
或no
,String
(s)被双引号括起来。此
public static void sd();
应该是
public static String sd() {
int singleyes = 5950;
int singleno = 11900;
boolean single = true;
if (single) {
StandardDeduction = "yes";
} else {
StandardDeduction = "no";
}
}
最后,分号作为无操作声明,不能出现在声明正文之外。