Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Length Conversions Frequently in life you'll need to convert from one unit to another: feet to meters, hours to seconds, degrees to radians, etc. Usually,
Length Conversions
Frequently in life you'll need to convert from one unit to another: feet to meters, hours to seconds, degrees to radians, etc. Usually, the conversion simply involves a simple conversion factor, meaning that you multiply or divide by a real number.
In this assignment, you'll input a length as some number of feet and inches, and convert that to a number of other length values. Finally, you'll print out the results in a nice format. See the examples below.
How to ask for user input: In your program you'll need to prompt the user to enter the number of feet and the number of inches to convert. The input function is not covered until slideset but it's pretty easy. To get the values of the feet and inches into two variables inputFeet and inputInches, you'll include the following two statements:
inputFeet inputEnter number of feet:
inputInches int inputEnter number of inches:
When each statement is executed, it prints the prompt eg "Enter number of feet: on the screen, and waits for the user to enter a number. After the user types in a number, say this number is read by the program as a string, say Then the function int will convert that string into the corresponding integer value which will be stored in the variable inputFeet. The second statement will do an analogous thing for variable inputInches. From there you're good to go Notice we didn't name those variables feet and inches because we'll use those for some other values.
You can assume that the year entered is a positive integer. It would be easy to convert this program to accept floats; that would only require changing one word in the input statements above. Can you guess what you'd change? Your program doesn't have to check that and doesn't have to work if the user enters a bad value. We won't test your program on illegal values.
Doing the conversions: After you've input those two values, you'll then do the conversions indicated in the following table. We suggest you do them in this order.
inches
inputFeet times plus inputInches
inches divided by
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