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

handsome nguyen
handsome nguyen
330 Points

I think I got it right but I keep getting the Bummer error. What's the real solution?

I'm not sure where I am getting this wrong. Please help. Thanks.

area.swift
// the height and width of a wall
let height = 120.0 // in inches
let width = 144.0 // in inches

let area = height * width
let areaInFeet = area / 12

1 Answer

Tommy Choe
Tommy Choe
38,156 Points

You just need to make sure you convert height and width from inches to feet first. Then multiply heightInFeet and widthInFeet together to get the areaInFeet.

Hope that helps!

handsome nguyen
handsome nguyen
330 Points

Hi Tommy,

So in the real world my way wouldn't work or is this simply just the way the only answer that the challenge will accept?

Thank you for answering my question. I'm just a little confused as to why the order of the conversion matters.

Tommy Choe
Tommy Choe
38,156 Points

It would have to do more with mathematics since the answer would be completely different. If you try doing the calculations, (height * width) / 12 ends up being much bigger than (height/12) * (width/12).

For (height * width)/12: (120 * 144)/12 = 1440

For (height/12) * (width/12): (120/12) * (144/12) = 120

The first equation can't be broken down into the second equation because they aren't equivalent mathematically. The second equation would only work if it was (height + width)/12 which would be equivalent to (height/12) + (width/12).

Since the second equation can't be derived from the first equation, the conversion from inches to feet must be done first.

Let me know if you have any other questions.