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 trialJordan Walters
Courses Plus Student 1,161 PointsHelp please.
struct Expense {
var description: String
var amount: Double = 0.0
init (description: String) {
self.description = description
}
func calculateTaxes(percentage: Double) -> Double{
return (self.amount)
}
}
struct Expense {
var description: String
var amount: Double = 0.0
init (description: String) {
self.description = description
}
func calculateTaxes(percentage: Double) -> Double{
return (self.amount)
}
}
Renato Nobre
5,805 PointsHey Jordan, if I remember well you should not return any value at this time of the task, it will tell you what to return in the next part
1 Answer
AR Ehsan
7,912 PointsHi. All you have to do is struct Expense { var description: String var amount: Double = 0.0
init (description: String) {
self.description = description
}
// add the calculateTaxes method here
// it should accept only one parameter named 'percentage' of type Double
func calculateTaxes(percentage: Double) -> Double {
return self.amount * (percentage/100)
}
}
var item = Expense(description: "Savings") item.amount = 100 var taxes = item.calculateTaxes(7.5)
Gloria Dwomoh
13,116 PointsGloria Dwomoh
13,116 PointsHi Jordan. I marked down your added code so it appears properly. To find out how to do that when you want to add some additional code you can check this post How to post code in the forums. Additionally, there is no question so it is hard for us to know what you need help with. Try adding more details on what you need help at.
Ps. Both codes are identical though.