Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Swift Basics (retired) Operators Binary Operators

The original code is in inches. How would I change it into feet? I also have no idea what the code would be help?

T

2 Answers

Jake Lundberg
Jake Lundberg
13,965 Points

you need to divide width and height by 12 (because there are 12 inches in a foot), and then multiply width in feet by height in feet (because to find the square footage, you use base x height = area).

hope this helps!

Thanks this is my code: It still won't work.

let height = 120.0 // in inches

let width = 144.0 // in inches

let area = height * width

let areaInFeet = area / 12

It says areaInFeet has the wrong value.

Jake Lundberg
Jake Lundberg
13,965 Points

they actually want you to do this:

area = (height / 12) * (width / 12);  // = 120 sq ft.

because if you do it your way:

height * width = 17280 inches 

17280 / 12 = 1440 sq ft...