Beau A.

asked • 08/25/22

Java: Kinetic Energy

Hi, I’ll first apologise as I am not very proficient at programming at all.

I’m having trouble with designing a program in Java for homework, I was wondering if I could get the solution to this problem to see where my code is wrong. The question is as follows:

Background:

A solid iron ball with a radius r and mass m is rolling on a surface without slipping with a constant linear velocity v and angular velocity ω. The total kinetic energy Kt of the ball is the sum of its linear kinetic energy Kl and its angular kinetic energy Ka where:

Kt=Kl + Ka

Kl = 1⁄2* m* v2

Ka = 1⁄2* I* ω 2


ω= v / r

the moment of inertia for a solid ball

I = 0.4*m*r2

m = 4/3 * π * r3 * ρ

where density ρ for iron is 7.8 kg/m3.


Coding Requirements:

Write a Java program (“KineticEnergy.java”) with a single class and three static methods, i.e., the main(), the linearEnergy() and the angularEnergy() methods, to calculate the Kinetic Energy for any given ball.


Further information / restrictions:

  1. You can use the methods predefined in Math class.
  2. Your program shall be compliable by Java JDK.
  3. Your program shall have only one class that contains three static methods.
  4. You should follow common programming practices and give meaningful identifiers to declared variables (avoid a, x, v, r, ...).
  5. Your program shall define symbolic constants for all values which have a physical meaning, are currently fixed, but there is a chance that they may be changed in future such as ρ for other materials. However, there is no need to define symbolic constants for those values which are permanently built into formulas and will never be changed.
  6. Your program shall use the printf() method to print the final output.
  7. In this question, you can presume that the user input always corrects (input verification is not required).
  8. Your program shall receive parameters in the following order:

- ball radius r (meters)

- ball linear velocity v (meters/second)


The program shall perform all calculations with double precision. The total kinetic energy shall be displayed with two decimal point precision.


The output example given is:

*** Kinetic energy calculation ***

Enter the following parameters

- Radius of the ball (m): 1.0

- Linear velocity of the ball (m/s): 1.0

The total kinetic energy is 22.87 (J)

The program has terminated


I’d like to see exactly what the code looks like that replicates the example using the information provided, as I seem to keep running into problems (possibly with indents)

I’d also like to know how the code could be altered if I was to use a different density (say for a lead ball)

Thanks in advance!!

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.