题目
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
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
提问时间:2021-01-04
答案
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!");
}
}
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,人们染上烟瘾,最终因吸烟使自己丧命.
最新试题
热门考点
- 1已知函数f(x)=2根号3sinxcosx-cos2x
- 2解方程:x²-2√5x-15=0
- 3什么情况下,一元二次方程的所有系数之和等于0
- 4比重原理是什么?
- 5中国银行和中国工商银行的性质区别在哪?
- 6加酶洗衣粉有什么好处?
- 7假设投入10kg原料,每件产品单重0.025kg,总产量为392件,试问耗料率约是多少?
- 8请您用简单的图示表示岩石风化过程
- 9计算:(1/2006-1)(1/2005-1)(1/2004)… (1/3-1)(1/2-1).
- 10一支刻度均匀但示数不准的温度计,挂在教室的墙面上,此时,温度计示数为28摄氏度.小明为了测量教室的真实温度,做了一项实验:在标准大气压下,把温度计放在冰水混合物上,摄氏度为8摄氏度,再把它放在沸腾的水