展开全部
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
int speed,hour;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print("What is the speed of the vehicle in mph?");
speed = Integer.parseInt(in.readLine());
System.out.print("How many hours has it traveled?");
hour = Integer.parseInt(in.readLine());
System.out.println("Hour Distance Traveled");
System.out.println("----------------------");
for(int i=1;i<=hour;i++){
System.out.println(i + " " + i*speed);
}
}
}
这段代码没有写那些拒绝输入负数和小数之类的细节,最主要是思想;下面是代码及运行结果截图
希望可以帮到你!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询