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 trialRio Weerasinghe
313 PointsIm not sure where I am going wrong.
I am following the tutorial on converting measurements but I am not sure exactly where I am going wrong. I have done the conversation by dividing inches by 12 but my areaInFeet is still not calculating the right amount
// the height and width of a wall
let height = 120.0 // in inches
let width = 144.0 // in inches
let area = height * width
// 1 sq. foot = 1 sq. inch / 12
let areaInFeet = area / 12
2 Answers
Florin Veja
6,912 PointsRio,
You are doing
height * width / 12
What you need is
(height / 12) * (width / 12)
Florin
kjvswift93
13,515 PointsThere is no need to create a whole other constant (you named it "area") to store the square feet in inches.
// the height and width of a wall
let height = 120.0 // in inches
let width = 144.0 // in inches
let areaInFeet = (height / 12) * (width / 12)
Misha Holtz
4,655 PointsMisha Holtz
4,655 PointsHey!
I noticed you are dividing your final area by a Int type. This is probably converting your areaInFeet to an Int, which might make the system think that it's the wrong answer when it's expecting a Double. Be careful when you are using different number types!