当我尝试运行这个程序时,我的问题是一切都可以编译,但是当我运行它时,它并没有吐出正确的结果。
例如,我想运行日期 14/12/2017,它说它是有效的一天
谁能帮我找出错误,或者“如果”之一是否定位或写错了?
import java.util.Scanner;
public class FutureDate {
public static void main (String args[]){
int inputMonth;
int inputDate;
int inputYear;
final int currentMonth = 10;
final int currentDate = 24;
final int currentYear = 2013;
final int numberOfDays = 31;
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter a month in format - mm: ");
inputMonth = keyboard.nextInt();
System.out.println("Enter a day in format - dd: ");
inputDate= keyboard.nextInt();
System.out.println("Enter a year in format - yyyy: ");
inputYear = keyboard.nextInt();
if (inputYear > currentYear && inputMonth > currentMonth && inputDate > currentDate)
System.out.println("Valid year");
if (inputMonth >= 1 && inputMonth <=12)
System.out.println("Valid Month");
if (inputMonth == 4 || inputMonth == 6 || inputMonth == 9 || inputMonth == 11 && inputDate >= 1 && inputDate <= 30)
System.out.println("Valid");
if (inputMonth == 2 && inputDate >= 1 && inputDate <= 28)
System.out.println("Valid Day");
if (inputDate >= 1 && inputDate <= 31)
System.out.println("Valid Day");
if (inputYear < currentYear)
System.out.println ("Invalid year");
if (inputDate < currentDate && inputMonth < currentMonth)
System.out.println ("Invalid day");
}
}