// exsw5.swift if, then, else conditional statements, switch case #if os(OSX) || os(iOS) // for libraries, portable for OSX and Linux import Foundation #elseif os(Linux) import Glibc #endif// print("exsw5.swift running") var x : Double = 2.0 // declare test variable var i = 3 if x < 3.0 { // < > <= >= == != compare operations print("compare < > <= >= == != x= \(x)") } if x > 3.0 || i == 3 && i > 2 { // || is or, && is and print("logic || is or, && is and i= \(i)") } if x > 3.0 { print("x > 3.0") } else if i < 3 { // optional print("i < 3") } else { // optional, get here if none of the above true print("none of the above") } // end if optional comment // switch case default statements var aval = 2 switch aval { case 1: print("case 1") case 2: print("case 2") default: print("none of above") } // end switch var vegetable = "watercress" switch vegetable { case "celery": print("Add some raisins.") case "cucumber", "watercress": print("That would make a good tea sandwich.") default: print("Everything tastes good in soup.") } print("exsw5.swift finished")