Question: JAVA Put all of the following in ONE program. Use comments to delineate each step. For example: public static void main( String astrCommandLine[ ] )

JAVA

Put all of the following in ONE program. Use comments to delineate each step. For example:

public static void main( String astrCommandLine[ ] )

{

// --------------------------------------------------------------------------------

// Problem 1: Age in seconds

// --------------------------------------------------------------------------------

< your code here>

...

// --------------------------------------------------------------------------------

// Problem 2: Volume of Sun, Earth and ratio of the two

// --------------------------------------------------------------------------------

< your code here>

...

// --------------------------------------------------------------------------------

// Problem 3: Number of molecules in 2.45 quarts of water.

// --------------------------------------------------------------------------------

< your code here>

...

}

You cannot use variables of data type double for any of the problems. You must use int and float.

Step 1

  • Calculate your age in seconds by:
    1. Calculating the number of seconds in a day.
    2. Calculating how many days you've been alive by multiplying the number of years since you were born by 365.
    3. Multiply the number of days you've been alive by the number of seconds per day and print the result.

Step 2

  • The diameter of the Sun is approximately 865,000 miles. The diameter of the Earth is approximately 7600 miles. Use methods in the Math library (e.g. Math.pow( base, exponent ) ) to calculate:
    1. The volume of the Sun in cubic miles. You'll need to Google for the calculation for volume of a sphere if you don't remember it or you can look in a math book.
    2. The volume of the Earth in cubic miles
    3. The ratio of the volume of the Sun to the volume of the Earth

Step 3

  • Calculate the number of molecules in 2.45 quarts of water. The mass of a single molecule of water is about 3.0 x 10-23 grams. A quart of water is about 950 grams.

Step 4

  • Be sure to test your answers!!! How do you do that? Well, that's part of the problem. Hint: how do you know the answers the computer gives you are correct? Try computing the answer with a calculator (Start / All Programs / Accessories / Calculator and use the Scientific View).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!