'我想要做什么:: 显示消息基于
早上好 (12am-12pm) 中午之后好 (12pm -4pm) 晚上好 (4pm 到 9pm) 晚安 (9pm 到 6am)'
import java.util.Calendar;
导入 java.util.GregorianCalendar;导入 java.util.Scanner;
公共类输入器{
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
GregorianCalendar time = new GregorianCalendar();
int hour = time.get(Calendar.HOUR_OF_DAY);
int min = time.get(Calendar.MINUTE);
int day = time.get(Calendar.DAY_OF_MONTH);
int month = time.get(Calendar.MONTH) + 1;
int year = time.get(Calendar.YEAR);
String name, address;
int age;
String greeting;
System.out.print("Name: ");
name = input.nextLine();
System.out.print("Address: ");
address = input.nextLine();
System.out.print("age: ");
age = input.nextInt();
if(hour>=1 && hour<=11){
greeting = "Morning";
} else if(hour<=15){
greeting = "Afternoon";
} else if(hour<=24){
greeting = "Evening";
System.out.println(" ");
System.out.println("Good " + greeting + ", " + name);
System.out.println("are you sure that you're " + age + " years ?" );
System.out.println("and live on " + address);
}
}
}