Calculating Area

From CompSciWiki
Revision as of 12:44, 1 April 2010 by TimC (Talk | contribs)

Jump to: navigation, search

Back to the Program-A-Day homepage

Problem

You have decided it's time to replace the carpet in your living room. The first step is to buy the correct amount of carpet for the area. To calculate the area, you must first measure the length and width of the living room. The area can then be calculated from these measurements, giving you the total square footage. The carpet you want costs $5 per square foot.

Your task is to write a small program that will accept as input the length and width (as integers) of a room. The program must then calculate the total cost of carpeting by multiplying the square footage by the price per square foot. Your program will print the total square footage and the total cost.

Use the following formulas:

Area = Length x Width
Total cost = Area x Cost per square foot

 

SideSectionTitle

float
Taken from http://www.flickr.com/photos/daniello/565304023/

An image or By Students section

Solution

The solution...

Code

SolutionCode goes here. Please DO NOT put your code in <pre> tags!

Back to the Program-A-Day homepage