Skip to content

Commit

Permalink
Swift 3 update
Browse files Browse the repository at this point in the history
The round(someDecimal) is the old C style. Doubles and floats have a built in Swift function now.
  • Loading branch information
Kibonakamura authored Nov 29, 2017
1 parent 172469f commit 7629e61
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions 2 - Operators/Solution.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ let mealCost = Double(readLine()!)!
let tipPercent = Int(readLine()!)!
let taxPercent = Int(readLine()!)!

let tip = Double(tipPercent) * mealCost / 100;
let tax = Double(taxPercent) * mealCost / 100;
let tip = Double(tipPercent) * mealCost / 100
let tax = Double(taxPercent) * mealCost / 100

let totalCost = round(tip + tax + mealCost);
print("The total meal cost is \(Int(totalCost)) dollars.")
let totalCost = tip + tax + mealCost
print("The total meal cost is \(Int(totalCost.rounded())) dollars.")

0 comments on commit 7629e61

Please sign in to comment.