Challenge # 9 Intances

Hello, good evening

I am doing challenge # 9 in the Lesson of Instances. And I am not sure if my code is right. Also I have a doubt if I made a correct choice in making numPerson Double in the division line.

import UIKit

struct TaxCalulator {

var tax = 1.16
func totalWithTax(a: Double) -> Double {
    return a * tax    
}

}

struct BillSplitter {

func splitBy(subTotal: Double, numPeople: Int) -> Double{
    
    let total = TaxCalulator()
    let check = total.totalWithTax(a: subTotal)
    let split = check / Double(numPeople)
    return split
}

}

var myCheck = BillSplitter()
var final = myCheck.splitBy(subTotal: 120, numPeople: 5)
print(final)

thank you so much!!!

@caroguajardoe

Hi Carolina,

If you got the result that you expected as the amount each must pay then you are all good. Wrapping numPeople with Double is right since it is an Int and check is a Double.

Well done.

Thank you very much!!!

good evening