title: App does not perform a simple calculation
body: <p><a href="https://i.stack.imgur.com/2Gzdj.png" rel="nofollow noreferrer">Xcode screenshot </a></p>
  
  <p>I have a simple app called BillSplitter that calculates a bill to display: input text fields for number of diners, bill total, and tip... 
  when I run the app the grandTotal output does not calculate properly... the total and the tip do not calculate.</p>
  
  <p>My app has 3 UITextfields Number of diners, Total cost of meal, and the tip. When I run the app and input data in the 3 fields and calculate My grand total is in correct. For example if I input. 2 diners, dinner cost $60, tip 10%. The result is as follows: The number of diners :2, Amount of Tip $6.00, Amount of bill: $60.00, Grand Total $70, each diner pays $30. What I should get is $66 for Grand Total and Each diner pays $33. </p>
  
  <p>My Code:</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
      @IBOutlet weak var dinersTextField: UITextField!  // number of diners
      @IBOutlet weak var totalCostTextField: UITextField! // bill total before
      @IBOutlet weak var resultTextLabel: UILabel!  // displays output of calculation
      @IBOutlet weak var tipTextField: UITextField!  // the tip
  
      override func viewDidLoad() {
          super.viewDidLoad()
      }
  
      @IBAction func calculate(_ sender: Any) {
          if let dinerStr = dinersTextField.text, let tipStr = tipTextField.text, let totalStr =   totalCostTextField.text, let diner = Double(dinerStr), let tip = Double(tipStr), let total =  Double(totalStr) {
              let formattedDiners = String(format: "%.0f", diner)
              let formattedCost = String(format: "%.2f", total)
              let formattedTip = String(format: "%.2f", (total * tip) / 100)
              let formattedGTotal = String(format: "%.2f", (total + tip))
              let formattedDinerPays = String(format: "%.2f", (total / diner))
  
              resultTextLabel.text = "The number of diners: \(formattedDiners)\nAmount of Tip: $\(formattedTip)\nAmount of bill: $\(formattedCost)\nGrand Total: $\(formattedGTotal)\nEach diner pays: $\(formattedDinerPays)"
          }
      }
      /// hide keyboard
      @IBAction func dismissKeyboard(_ sender: Any) {
          view.endEditing(true)
      }
  }
  </code></pre>