Answer to Question #289598 in Java | JSP | JSF for denz

Question #289598

In physics, an object that is in motion is said to have kinetic energy. The following formula can be used to determine a moving object’s kinetic energy:

K E = 1 2 m υ 2 


The variables in the formula are as follows: KE is the kinetic energy, m is the object’s mass in kilograms, and v is the object’s velocity in meters per second.

Create a Java program with a function that accepts an object’s mass (in kilograms) and velocity (in meters per second) as arguments. The function should return the amount of kinetic energy that the object has. Ask the user to enter values for mass and velocity, and then call the function you created to get the object’s kinetic energy. 


sample output:

Enter mass in kilograms: 71

Enter velocity in meters per second:  5.5

The object's kinetic energy is: 1073.88 J.



1
Expert's answer
2022-01-21T14:38:44-0500


import java.util.*;


public class App {


	/**
	 * The start point of the program
	 * 
	 * @param args
	 * 
	 */
	public static void main(String[] args) {
		Scanner keyBoard = new Scanner(System.in);


		System.out.print("Enter mass in kilograms: ");
		double mass = keyBoard.nextDouble();
		System.out.print("Enter velocity in meters per second: ");
		double velocity = keyBoard.nextDouble();
		double E = calculateE(mass, velocity);
		System.out.printf("The object's kinetic energy is: 1073.88 J.\n\n", E);


		keyBoard.close();
	}


	static double calculateE(double mass, double velocity) {
		return (mass * velocity * velocity) / 2.0;
	}


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

denz
22.01.22, 02:04

it's really work. Thank you so much ^^

Leave a comment

LATEST TUTORIALS
New on Blog