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

Jorge Ayala
Jorge Ayala
1,025 Points

How do you find the area in feet of constants given the area and width in inches.

height is 120.0 inches width is 144.0 inches and they're both constants "let"

// the height and width of a wall
let height = 120.0 // in inches
let width = 144.0 // in inches
// 1 foot = 12 inches
let area = (height * width) / 12 

If I understood the question.

Anjali Pasupathy
Anjali Pasupathy
28,883 Points

You need to divide by 144, not 12. height and width are both in inches, so you need to convert both to feet.

let height = 120.0 // in inches
let width = 144.0 // in inches
 Converting inches to feet:
   heightInFeet = height / 12
   widthInFeet = width / 12
 Calculating area:
   areaInSquareFeet = heightInFeet * widthInFeet
   areaInSquareFeet = (height / 12) * (width / 12)
   areaInSquareFeet = height * width / (12 * 12)
   areaInSquareFeet = height * width / 144
let area = height * width / 144

Thanks for the correction Anjali :)

Jorge Ayala
Jorge Ayala
1,025 Points

Thank you for the help, I can see where I was making the mistake and corrected it.