Answer to Question #323702 in Java | JSP | JSF for Kaira

Question #323702

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:

KE=1/2mv2

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.

 

1. Write a function named kinetic_energy 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. 

 

2. Write a statement that calls the kinetic_energy function to get and display the kinetic energy of an object with the mass of 5 kilograms and velocity of 20 meters per second

 


1
Expert's answer
2022-04-04T19:55:50-0400
import java.util.Scanner;
public class Function {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Func f=new Func();
        int operatorm=5;
        int operatorv=20;
        System.out.println("It's the kinetic energy of an object with the mass of 5 kilograms\n" +
                "and velocity of 20 meters per second: " +f.kineticEnergy(operatorm,operatorv));
        System.out.print("Enter mass of your object: ");
        int massS = scan.nextInt();
        System.out.print("Enter velocity of your object: ");
        int veloc = scan.nextInt();
        System.out.println("Kinetic energy: "+f.kineticEnergy(massS,veloc));
    }
}
class Func{
        double kineticEnergy(int mass, int velocity) {
            return (double) (mass * (velocity * velocity)) / 2;
        }
}

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

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS