7Area of a Rectangular Room

When working in a global environment, you’ll have to present information in both metric and Imperial units. And you’ll need to know when to do the conversion to ensure the most accurate results.

Create a program that calculates the area of a room. Prompt the user for the length and width of the room in feet. Then display the area in both square feet and square meters.

Example Output

 
What is the length of the room in feet? 15
 
What is the width of the room in feet? 20
 
You entered dimensions of 15 feet by 20 feet.
 
The area is
 
300 square feet
 
27.871 square meters

The formula for this conversion is

images/_pragprog/svg-0001.png

Constraints

  • Keep the calculations separate from the output.

  • Use a constant to hold the conversion factor.

Challenges

  • Revise the program to ensure that inputs are entered as numeric values. Don’t allow the user to proceed if the value entered is not numeric.

  • Create a new version of the program that allows you to choose feet or meters for your inputs.

  • Implement this program as a GUI program that automatically updates the values when any value changes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.1.51