我想知道是否有一种简单的方法来显示错误字符或无效输入数据的错误。
public static void main(String[] args) { // Step 1: Create new Scanner object. Scanner input = new Scanner(System.in); // Step 2: Prompt the user to enter today's day. System.out.print("Enter today’s day as an Integer (0-6): "); int Today = input.nextInt(); // Step 3: Prompt the user to enter the number of days elapsed since today. System.out.print("Enter the number of days elapsed since today as an Integer: "); int DaysElapsed= input.nextInt(); // Step 4: Compute the future day. int FutureDay = (Today + DaysElapsed) % 7; // Step 5: Printing the results. // Step 5.1: Today's day result depending the case. System.out.print("Today is "); // Step 5.2: Future day result depending the case. System.out.print(" and the future day is ");
慕妹3146593
牛魔王的故事
相关分类