Swift Calculation

Run Settings
LanguageSwift
Language Version
Run Command
print("First number:") let num1 = Double(readLine(strippingNewline: true) ?? "2" ) ?? 1 print("Second number:") let num2 = Double(readLine(strippingNewline: true) ?? "2" ) ?? 1 let operat = readLine(strippingNewline: true) ?? "+" print("请输入运算符(+、-、*、/):\(num1) \(operat) \(num2)") var result: Double! switch operat { case "+": result = num1 + num2 case "-": result = num1 - num2 case "*": result = num1 * num2 case "/": result = num1 / num2 default: print("Not valid") break } print("the result is:\(result)")
Editor Settings
Theme
Key bindings
Full width
Lines