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

Omotayo Olawepo
Omotayo Olawepo
2,803 Points

hey guys could you guys help me, i've been stuck on this for a while

Given the height and width of a wall in inches, calculate the area in square feet and assign it to a constant named areaInFeet. (HINT: The width and height are constants, so they themselves won't change.)

area.swift
// the height and width of a wall
let height = 120.0 // in inches
let width = 144.0 // in inches
var area = height + width
let areaInFeet = Double(area) / 10.764

1 Answer

area = height * width given the same units of measure but in this challenge they give you the height and width in inches.

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

They want the area in feet so we will have to divide the height and width by 12 to get the feet. We then have to multiply the result of both the height in feet and the width in feet to get the area We can do this all in one line of code:

let areaInFeet = (height/12) * (width/12)