Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Einstein’s famous formula E = MC2 gives the amount of energy released by the com

ID: 667676 • Letter: E

Question

Einstein’s famous formula E = MC2 gives the amount of energy released by the complete conversion of matter of mass M into energy E. If M represents the mass in kilograms and C represents the speed of light in meters per second (3.0 * 108 m/s), then the result is in the energy unit Joules. It takes 36000 Joules to light a 100 watt light bulb for an hour. Write a Java program that calculates the energy and the number of light bulbs that could be powered by a given mass of matter. Input a double value from the keyboard, and use scientific notation (E notation) and printf statements. Output should look similar to below.

Sample Run:

This mass could provide 9E+14 Joules of energy.
It could power 2.5E+09 100 watt light bulbs for an hour.

Explanation / Answer

/**The java program that prompts the user to enter the mass in the
* kgs and then calculates the energy realsed by the mass
* prints energy and number of bulbs that could power with
* given mass*/

//MassEnergyProgram.java
import java.util.Scanner;
public class MassEnergyProgram
{
   //Initialize light speed 3x10 power 8 m/sec
   static final double SPEED_OF_LIGHT = 3E8;
   //energy required to power 100 watt bulb for 1 hour
   static final int ENERTY_PER_100WATTBULB = 36000;

    public static void main(String[] args)
    {
       //Create an instance of Scanner class
       Scanner input = new Scanner (System.in);
      
       System.out.println("Enter the mass in kg:");
       //read mass value from the user
       double mass = input.nextDouble ();
      
      
       //calculate the energy released for given mass
        double energy = mass * SPEED_OF_LIGHT * SPEED_OF_LIGHT;
      
        System.out.println("This mass could provide " + energy+" Jouls of energy");      
       System.out.println("It could power " + energy / ENERTY_PER_100WATTBULB+
               " 100 watt light bulbs for an hour.");
      
    }//end of the main method
  
}//end of the class

-------------------------------------------------------------------------------------------------------------------

Sample Output:

Enter the mass in kg:
0.01
This mass could provide 9.0E14 Jouls of energy
It could power 2.5E10 100 watt light bulbs for an hour.

Hope this helps you

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote