You are viewing a single comment's thread. Return to all comments →
This works. (You can also use lround (returns a Int, which is the exercise's requirement for the output)):
import Foundation let mealCost: Double = Double(readLine()!)! let tipPercent: Int = Int(readLine()!)! let taxPercent: Int = Int(readLine()!)! func tip() -> Double { return mealCost * (Double(tipPercent) / 100) } func tax() -> Double { return mealCost * (Double(taxPercent) / 100) } func totalCost() -> Int { return lround(mealCost + tip() + tax()) } print("The total meal cost is \(totalCost()) dollars.")
Seems like cookies are disabled on this browser, please enable them to open this website
Day 2: Operators
You are viewing a single comment's thread. Return to all comments →
This works. (You can also use lround (returns a Int, which is the exercise's requirement for the output)):