Hello everyone there.

I have a problem with java exercise so can you help me?

I would like you to show me detail and clear about all these exercise.

1. Write a console program to define and initialize a variable of type byte to 1, and then successively multiply it by 2 and display its value 8 times. Explain the reason for the last result.

2. Write a console program to declare and initialize a double variable with some value such as 1234.5678. Then retrieve the integral part of the value and store it in a variable of type long, and the first four digits of the fractional part and store them in an integer of type short. Display the value of the double variable by outputting the two values stored as integers.

3. Write a program that defines a floating-point variable initialized with a dollar value for your income and a second floating-point variable initialized with a value corresponding to a tax rate of 35 percent. Calculate and output the amount of tax you must pay with the dollars and cents stored as separate integer values (use two variables of type int to hold the tax, perhaps taxDollars and taxCents).

4. The diameter of the Sun is approximately 865,000 miles. The diameter of the Earth is approximately 7,600 miles. Use the methods in the class Math to calculate:

❑ The volume of the Earth in cubic miles
❑ The volume of the Sun in cubic miles
❑ The ratio of the volume of the Sun to the volume of the Earth

Hope you can help and clear explanation for this. I really want to understand.

thanks in advance!

That's your homework, my friend, and it's yours to do and it's yours to learn from. If you have questions, you might get answers, or at least hints, but you're not likely to get anyone to do your work for you.


thank for your advice, if i have any question, i will ask and will try to do it as well. On contrary, Can u tell me the formula or the key word that make me understand than this?

thank in advance.

Can u tell me the formula or the key word that make me understand than this?

You posted 4 questions. Where are you having problems? There is no keyword for all of them. About the 1st, don't you know how to initialize variables? Ask specific questions.

Study and then tell use what you don't understand

In short, show some effort. Problems with code? we'll be happy to help - post the code that you have wrote so far, and tell us exactly what is the problem.

commented: Someone downticked this post, just correcting their error. :) +1