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 trialDavid Rodriguez Saavedra
3,574 Pointswhat value should i give to var taxes?
please some one help!!
struct Expense {
var description: String
var amount: Double = 0.0
init (description: String) {
self.description = description
}
func calculateTaxes(percentage: Double) -> Double{
return self.amount * (percentage/100.00)
}
}
var item = Expense(description: "hello")
item.amount = 7.5
item.calculateTaxes(percentage: Double)
var taxes = calculateTaxes(percentage)
1 Answer
Chase Marchione
155,055 PointsHi David,
Challenge 3 asks us to set item.amount to 100, so we'll do that.
As for Challenge 4, we'll pass in 7.5 as an argument to the calculateTaxes method (this 7.5 will be the tax percentage, as you've defined in the calculateTaxes method's header.) We need to specify our variable of item when calling this method (which is an instance of Expense), because item's amount property holds the value that we want to calculate taxes on.
var item = Expense(description: "hello")
item.amount = 100
var taxes = item.calculateTaxes(7.5)
Hope this helps!