Java Chapter 3 HW
Java Chapter 3 HW
HW Chap 03
Name: Md. Jeyson Jaman Sawan
Roll: CSE202101001
Level 1 Programming Exercises★
07. Write a program to convert centimeters (input) to feet and inches (output). 1 in = 2.54 cm.
Solution:
08. Write a program that inputs temperature in degrees Celsius and prints out the temperature
in degrees Fahrenheit. The formula to convert degrees Celsius to equivalent degrees Fahrenheit
is Fahrenheit = 1.8 * Celsius + 32
Solution:
Level 2 Programming Exercises ★★
15. The velocity of a satellite circling around the Earth is computed by the formula
𝐺𝑀𝐸
V=√ 𝑟
Where 𝑀𝐸 = 5.98 X 1024 kg is the mass of the Earth, r the distance from the center of the Earth to the
satellite in meters, and G = 6.67 X 10−11 m3/kg • s2 the universal gravitational constant. The unit of the
velocity v is m/s. Write a program that inputs the radius r and outputs the satellite’s velocity. Confirm that
a satellite that is closer to the Earth travels faster. Define symbolic constants for 𝑀𝐸 and G. The distance
to the Hubble Space Telescope from the center of the Earth, for example, is approximately 6.98X106 m.
Solution:
Level 3 Programming Exercises ★★★
24. Write a program that accepts the unit weight of a bag of coffee in pounds and the number of bags
sold and displays the total price of the sale, computed as
where 5.99 is the cost per pound and 0.0725 is the sales tax.
Solution: