3848 - 2.23物理方面:加速度

通过次数

0

提交次数

0

时间限制 : 1 秒 内存限制 : 128 MB

(物理方面:加速度)平均加速度定义为速度的变化量除以这个变化所用的时间,如下式所示:

                  a=(v1-v0)/t

编写程序,提示用户输入以米/秒为单位的起始速度v0,以米/秒为单位的终止速度v1,以及以秒为单位的时间段,最后显示平均加速度。

题目输入

在屏幕上显示这段文字Enter v0,v1,and t :  输入数据

题目输出

在屏幕上显示这段文字The average acceleration is:  显示结果

输入/输出样例

输入格式

Enter v0,v1,and t : 5.5  50.9  4.5 

输出格式

The average acceleration is 10.0889   

Java解答

import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner input=new Scanner(System.in);
double v0=5.5;
double v1=50.9;
double t=4.5;
double a1=Math.round((v1-v0)*10000/t);
double a=a1/10000;
System.out.printf("The average acceleration is "+a);
	}

}