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:
- Calculating the number of seconds in a day.
- Calculating how many days you've been alive by multiplying the number of years since you were born by 365.
- 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:
- 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.
- The volume of the Earth in cubic miles
- 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started