즉각적인 문제가 누락 열린 중괄호 ({
가)이며 폐쇄 괄호 ()
)
BufferReader
으로 그러한 클래스가 없습니다
public static void main(String[] args) {
^--- This is important...
Scanner input = new Scanner(System.in);
^--- Also important :P
BufferReader br = new BufferReader(instream);
System.out.println("Enter your annual sales");
String annual = br.readLine();
int salary = 75_502_81;
int com = 38_28;
int compensation = annual * com + salary;
}
, 난 당신이 그런 변수 instream
요에 선언되지 있습니다 BufferedReader
의미 생각 u 코드, 나는 당신이 input
을 의미 할 수도 있다고 생각하지만, BufferedReader
은 유효한 입력 유형으로 input
을 취하지 않으므로 여기에 의도가 무엇인지 확실하지 않습니다.
캐치되지 않는 IOException
당신은 내가 또한 75_502_81
및 38_28
이 의미하는 가정하는 것에 대해 궁금 try-catch
의 사용을 통해이를 해결할 수 있습니까? int
값은 숫자 이외의 값을 포함 할 수 없습니다 ...
annual
또한입니다. 즉, 어떤 수학 연산도 수행 할 수 없음을 의미합니다.
당신은 먼저 int
에 값을 변환해야합니다 ...
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
BufferedReader br = null;
try {
br = new BufferedReader(instream);
System.out.println("Enter your annual sales");
String annual = br.readLine();
int salary = 7550281;
int com = 3828;
int compensation = Integer.parseInt(annual) * com + salary;
} catch (IOException exp) {
exp.printStackTrace();
} finally {
try {
br.close();
} catch (Exception exp) {
}
}
}
하지만
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter your annual sales");
String annual = input.nextLine();
int salary = 7550281;
int com = 3828;
int compensation = Integer.parseInt(annual) * com + salary;
}
이 같은 일을 할 때 왜에 나의 머리를 긁적 왼쪽 해요 ...
오른쪽 괄호가 누락되었습니다. 그리고 왼쪽 버팀대. – Makoto
이것도 마찬가지입니다. 파일에 쓰는 것과 아무런 관련이 없습니다. – MadProgrammer
int에는 _과 같은 특수 문자가 있어서는 안됩니다. 제거하십시오. – Hariharan