how to write this java program

how to write this java program

题目
how to write this java program
the question is:The height of an object dropped from a starting height of 100 meters is govern by the equation h=100-4.9*t^2 where t is the time in seconds.Write a program that asks the user for a time less than 20 seconds and displays the height of the object at that time using this formula.The output should look similar to:
Enter the time:2
The object is at 80.4 meter
im in usa·this is my computer homework·i cannot type in Chinese·sorry
答案
hi,here is my program.
it is my pleasure to help u!
import java.util.Scanner;
public class App {
/**
* @param args
*/
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int time = 0;
do {
System.out.println("Please input a time less than 20 seconds!");
time = s.nextInt();
} while (time >= 20 || time < 0);
System.out.println("The object is at " + (100 - 4.9 * time * time)
+ " meter!");
}
}
举一反三
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
1,人们染上烟瘾,最终因吸烟使自己丧命.
最新试题
热门考点

超级试练试题库

© 2017-2019 超级试练试题库,All Rights Reserved.