Difference between revisions of "Calculating Area"

From CompSciWiki
Jump to: navigation, search
Line 7: Line 7:
 
Use the following formulas:
 
Use the following formulas:
  
Square footage = Length x Width
+
Area = Length x Width
<BR>Total cost = Square footage x Cost per square foot
+
<BR>Total cost = Area x Cost per square foot
  
 
|SideSection=
 
|SideSection=

Revision as of 12:44, 1 April 2010

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