Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

There are two enhancements for the Standard version over the Minimal version: Adjust the echoed height in feet and inches. Ask for a second height

There are two enhancements for the Standard version over the Minimal version:

Adjust the echoed height in feet and inches.
Ask for a second height in centimeters and convert it to feet and inches.

The program will still assume that the user input is accurate. If unexpected values are entered, the behavior is "undefined".

Adjust the Echoed Height in Feet and Inches

The program will work if the user inputs "goofy" values.

Please enter the height to be converted.
First, enter the feet: 2
Now, enter the inches: 30

Your height is 2 feet 30 inches, or 54 inches. That is 137.16 cm.

Or even:

Please enter the height to be converted.
First, enter the feet: 6
Now, enter the inches: -2

Your height is 6 feet -2 inches, or 70 inches. That is 177.80 cm.

[participation fodder: Why does this work, even if the inches are greater than 11 or less than 0?]

For this enhancement, alter the output to report the "appropriate" values for feet and inches. So, our "goofy" examples become:

Please enter the height to be converted.
First, enter the feet: 2
Now, enter the inches: 30

Your height is 4 feet 6 inches, or 54 inches. That is 137.16 cm.

and

Please enter the height to be converted.
First, enter the feet: 6
Now, enter the inches: -2

Your height is 5 feet 10 inches, or 70 inches. That is 177.80 cm.

Hint: Work "backwards" from the calculated total inches. How many whole feet is that? (integer division) How many inches are left over? (remainder)

Centimeters to Inches

For the Standard version, the program shall ask for a second height, this time in centimeters. Assume that the input value is integer. The program will now convert that height in centimeters to inches and report that height in decimal inches. Print out the inches with three places following the decimal point. Here is an example of the second half of the program.

Please enter a second height to be converted.
Enter the height in centimeters: 175

Your height is 175 cm, or 68.898 inches.

To convert from centimeters to inches, we "reverse" the process. That is, divide by 2.54, rather than multiply.

Sample runs, Standard version

So, here is an example of the full program run:

Please enter the height to be converted.
First, enter the feet: 6
Now, enter the inches: -2

Your height is 5 feet 10 inches, or 70 inches. That is 177.80 cm.

Please enter a second height to be converted.
Enter the height in centimeters: 175

Your height is 175 cm, or 68.898 inches.

Please note: The program first asks for integer feet, then integer inches, finally integer centimeters. The first two values work together to provide the first height value, in feet and inches. The third input value is the second height value, in centimeters.

In the Standard version, there are six values that vary based on the input values: four, based on the feet and inches input (highlighted in yellow), and two, based on the centimeter input (highlighted in cyan).

Please enter the height to be converted.
First, enter the feet: 6
Now, enter the inches: -2

Your height is 5 feet 10 inches, or 70 inches. That is 177.80 cm.

Please enter a second height to be converted.
Enter the height in centimeters: 175

Your height is 175 cm, or 68.898 inches.

Step by Step Solution

3.40 Rating (162 Votes )

There are 3 Steps involved in it

Step: 1

Python program to converts height between feet inches and centimeters Function to convert feet and inches to centimeters def feetandinchestocmfeet inches totalinches feet 12 inches centimeters totalin... blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Primer Plus

Authors: Stephen Prata

6th Edition

978-0321776402, 0321776402

Students explore these related Programming questions

Question

What is Accounting?

Answered: 3 weeks ago

Question

Define organisation chart

Answered: 3 weeks ago

Question

What are the advantages of planning ?

Answered: 3 weeks ago

Question

What Is acidity?

Answered: 3 weeks ago