import java.util.Scanner;
import java.util.InputMismatchException;
public class backup {
public static int t1;
public static int t2;
public static int x;
public static int y1;
public static int m1;
public static int d1;
public static int y2;
public static int m2;
public static int d2;
public static void date1() {
Scanner scanner = new Scanner(System.in);
try {
System.out.println("Please enter the first date ");
System.out.println("Please enter the year: ");
y1 = scanner.nextInt();
System.out.println("Please enter the month: ");
m1 = scanner.nextInt();
System.out.println("Please enter the day: ");
d1 = scanner.nextInt();
} catch (InputMismatchException inputMismatchException)
{
scanner.nextLine();
System.err.println("You must enter intergers. Please try again. "); }
}
public static void caldate1() {
int j = 693502;
if (t1 > j) {
if (m1 == 1 + 3 + 5 + 7 + 8 + 10 + 12) {
t1 = ((365 * y1) + d1 + 31);
} else if (m1 == 2) {
t1 = ((365 * y1) + d1 + 28);
} else if (m1 == 4 + 6 + 9 + 11)
;
{
t1 = ((365 * y1) + d1 + 30);
}
}
else {
System.err.printf("Error. Please enter a date after Jan 1st 1900.\n");
}
}
public static void main(String[] args) {
date1();
caldate1();
}
}
두 번째 오류는 첫 번째 방법에서 오류가 발생할 때 나타납니다. 누구든지이 원인을 알 수 있습니까? 아니면 내가 뭘 잘못하고 있니? 사용자가 정수가 아닌 다른 값을 입력하면 오류가 발생합니다. 또한 누구든지 오류가 적용될 때 각 메서드에 루프를 설정할 수있는 방법을 알고 있습니까?다른 방법의 오류 메시지가 나타나는 이유는 무엇입니까?