0% found this document useful (0 votes)
17 views

Java Chapter 3 HW

This document contains programming exercises of varying difficulty levels with solutions. It includes exercises to convert between centimeters and feet/inches, Celsius and Fahrenheit temperatures, and calculate the velocity of a satellite and total price of coffee bags including tax. Symbolic constants are used for the mass of the Earth and gravitational constant in one calculation.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Java Chapter 3 HW

This document contains programming exercises of varying difficulty levels with solutions. It includes exercises to convert between centimeters and feet/inches, Celsius and Fahrenheit temperatures, and calculate the velocity of a satellite and total price of coffee bags including tax. Symbolic constants are used for the mass of the Earth and gravitational constant in one calculation.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

PMSCS OOP 602

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

totalPrice = unitWeight * numberOfUnits * 5.99;

totalPriceWithTax = totalPrice + totalPrice * 0.0725;

where 5.99 is the cost per pound and 0.0725 is the sales tax.

Solution:

You might also like