1.12(以千米计的平均速度)假设一个跑步者1小时40分35秒跑了24英里。编写一个程序显示以每小时多少千米为单位的平均速度值。(注意,1英里等于1.6千米。) 1.12 (Average speed in kilometers) Assume that a runner runs 24 miles in 1 hour, 40 minutes, and 35 seconds. Write a program that displays the average speed in kilometers per hour. (Note 1 mile is equal to 1.6 kilometers.)
参考代码:
package chapter01;publicclassCode_12{publicstaticvoidmain(String[] args){finalint RUNNING_TIME =1*3600+40*60+35;//the time of running in secondsfinalint RUNNING_MILES =24;double running_kilometers =24*1.6;double runner_speed_kilo_hour = running_kilometers / RUNNING_TIME *3600;
System.out.println("The speed of the runner is (kilometers per hour) : "+ runner_speed_kilo_hour);}}
结果显示:
The speed of the runner is (kilometers per hour):22.90637945318973
Process finished with exit code 0
第一章第十二题(以千米计的平均速度)(Average speed in kilometers)1.12(以千米计的平均速度)假设一个跑步者1小时40分35秒跑了24英里。编写一个程序显示以每小时多少千米为单位的平均速度值。(注意,1英里等于1.6千米。)1.12 (Average speed in kilometers) Assume that a runner runs 24 miles in 1 hour, 40 minutes, and 35 seconds. Write a program t