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

Im 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

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 

// 1 sq. foot = 1 sq. inch / 12
let areaInFeet = area / 12 
Misha Holtz
Misha Holtz
4,655 Points

Hey!

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!

2 Answers

Rio,

You are doing

height * width / 12

What you need is

(height / 12) * (width / 12)

Florin

There 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)