115k views
1 vote
1. Convert a distance from miles to kilometers. There are 5,280 feet per mile, 12 inches per foot, 2.54 centimeter per inch and 100,000 centimeters per kilometers. Format your output to have two decimal places.

2. Write a program to convert a measurement in centimeters to feet and inches. The number of centimeters should be read as input. There are 2.54 centimeters in each inch and 12 inches in each foot. Format your output to have two decimal places.
3. Write a program that will read a weight in pounds and convert it to grams. Print both the original weight and the converted value. There are 454 grams in a pound. Format your output to have two decimal places.
4. Write a program that inputs a number of hours and output the equivalent number of weeks, days and hours.
5. Write a program that will convert the read-in time in seconds to number of hours, minutes and seconds.

User Sash Zats
by
8.6k points

1 Answer

6 votes

Final answer:

The question deals with converting different units of measurements such as miles to kilometers, centimeters to feet and inches, pounds to grams, and time conversions in hours to weeks, days, and hours, and seconds to hours, minutes, and seconds.

Step-by-step explanation:

Conversions between Measurement Systems

To convert a distance from miles to kilometers, we can use the provided factors. Since there are 5,280 feet in one mile and 12 inches in one foot, this means there are a total of 63,360 inches in one mile (5,280 feet/mile * 12 inches/foot). Each inch is equivalent to 2.54 centimeters, so a mile is 160,934.4 centimeters (63,360 inches * 2.54 centimeters/inch).

Since there are 100,000 centimeters in a kilometer, we can convert the total centimeters in a mile to kilometers: 1 mile = 160,934.4 centimeters / 100,000 centimeters/kilometer = 1.609344 kilometers. Formatting the output, we obtain 1.61 kilometers to two decimal places.

To convert a measurement in centimeters to feet and inches, we divide the number of centimeters by 2.54 to get the total inches. Every 12 inches make up one foot, so we divide the total inches by 12 to get the number of feet and use the remainder as the inch portion. With 30.48 centimeters in a foot, we can also directly convert feet to centimeters by multiplication.

For converting a weight in pounds to grams, we use the fact that there are 454 grams in one pound. We multiply the weight in pounds by 454 to obtain the weight in grams.

When converting a number of hours into weeks, days, and hours, we divide the total hours by 168 to get the number of weeks (since there are 168 hours in a week), take the remainder and divide it by 24 to get the number of days, and use the remainder of the last division as the hours.

To convert time in seconds to number of hours, minutes, and seconds, we divide the total seconds by 3,600 to find hours (since there are 3,600 seconds in an hour), take the remainder to divide by 60 for minutes and the last remainder will be the seconds.

User Davisoski
by
8.2k points

No related questions found