Computer Applications
Write a program in Java to compute the final velocity of a vehicle using the following formula:
where, u = initial velocity, a = acceleration and s = distance covered; they are entered by the user.
Java
Java Math Lib Methods
29 Likes
Answer
import java.util.Scanner;
public class KboatVelocity
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter initial velocity: ");
double u = in.nextDouble();
System.out.print("Enter acceleration: ");
double a = in.nextDouble();
System.out.print("Enter distance covered: ");
double s = in.nextDouble();
double v = Math.sqrt(u * u + 2 * a * s);
System.out.println("Final Velocity = " + v);
}
}
Output
Answered By
11 Likes
Related Questions
Write a program to compute and display the value of expression:
where, the values of x, y and z are entered by the user.
Write the equivalent Java statements for the following, by using the mathematical functions:
i. Print the positive value of -999.
ii. Store the value -3375 in a variable and print its cube root.
iii. Store the value 999.99 in a variable and convert it into its closest integer that is greater than or equal to 999.99.
Write a program to generate random integers in the following ranges:
i. 10 to 20 (both inclusive)
ii. 25 to 50 (both inclusive)Write a program that accepts a number x and then prints:
x0, x1, x2, x3, x4, x5