作业帮 > 综合 > 作业

帮忙编写一个java程序(很基础的那种).

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/07/05 08:11:42
帮忙编写一个java程序(很基础的那种).
Write a program which accepts a time interval in seconds and prints the equivalent time in hours minutes seconds.One hour is 3600 seconds and one minute is 60 seconds.
public class TimeTran {

public static void translation(int seconds){
int hh = seconds/3600;
int mm = (seconds - hh * 3600)/60;
int ss = seconds - hh * 3600 - mm * 60;
System.out.println("时间转换之后为" + hh + "小时" + mm + "分" + ss + "秒");
}
public static void main(String[] args) {
translation(3601);
}
}