public class Test_3 {
//将一分钟换算成秒
static final int MINUTE = 60;
//将小时换算成秒
static final int HOUR = MINUTE * 60;
//将一天换算成秒
static final int DAY = HOUR * 12;
public static void main(String[] args) {
int number = 0;
number = getNumber();
printTime(number);
}
public static int getNumber() {
int number = 0;
Scanner input = new Scanner(System.in);
System.out.println("please input a number:");
number = input.nextInt();
input.close();
return number;
}
public static void printTime(int number) {
//时间大于一天
if (number >= DAY) {
int numDay = number / DAY; //获得天数
number = number % DAY; //剩下不足一天的秒数
System.out.print(numDay + "天");
}
//时间大于一小时
if (number >= HOUR) {
int numDay = number / HOUR; //获得小时数
number = number % HOUR; //剩下不足一小时的秒数
System.out.print(numDay + "小时");
}
//时间大于一分钟
if (number >= MINUTE) {
int numDay = number / MINUTE; //获得分钟数
number = number % MINUTE; //剩下不足一分钟
System.out.print(numDay + "分");
}
if (number != 0) {
System.out.println(number + "秒");
}
}