The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
| 0down vote favorite |
I am receiving an expected declaration error at the do { line. I have tried researching this and read over the Apple developer information for Swift 3 on try/catch statements but have not been able to figure this out. Any help would be appreciated. |
Â
////Calculator.swift//KellyWeek1////Created by Kelly Heath on 9/28/16.//Copyright © 2016 Kelly Heath. All rights reserved.//import Foundationimport UIKitclass Calculator: ViewController {var numerator : Float?var denominator : Float?var total : Float?var display = "0"enum divisionErrors: Error {case infcase nan}func divide(num: Float, by denum: Float) throws -> Float {guard num != 0 else{throw divisionErrors.nan}guard denum != 0 else{throw divisionErrors.inf}let computedValue = num / denumreturn computedValue}do {catch divisionErrors.inf {print("Error")}display = "0"catch divisionErrors.nan {print("Error")}display = "0"}}