真心求指导JAVA题目怎么做啊,有几题不会做

2024-10-31 15:20:48
推荐回答(1个)
回答1:

public class Time{
public Date() {
this(System.currentTimeMillis());
}
}

public class TimeDemo{
public static void main(String[] args) {
Time t= new Time ();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(df.format(t.Date());
}
}

public class MySumDemo {
public static void main(String[] args) {
Scanner s1 = new Scanner(System.in);
System.out.println("请输入第一个数字并回车:");
int a = s1.nextInt();
System.out.println("请输入第二个数字并回车:");
int b = s1.nextInt();
System.out.print("两次输入结果之和为:");
System.out.println(a+b);
}
}

public class NumDemo{
public static void main(String[] args) {
for(int i =1 ;i<=1000;i++){
if(i%3==0 && i%5==0){
System.out.println("依次结果为:"+i);
}
}
}
}