// Sentence.swift Copyright (c) Kari Laitinen // http://www.naturalprogramming.com // 2014-09-30 File created. // 2015-10-17 Last modification. // This program demonstrates a switch-case construct that uses // the fallthrough keyword. import Foundation print( "\n Type in L, M, or S, depending on whether you want" + "\n a long, medium, or short sentence displayed: ", terminator: "" ) // Although the name of the following variable says // 'character' we will receive a String from the keyboard. var character_from_keyboard : String! = readLine() print( "\n This is a", terminator: "" ) switch ( character_from_keyboard ) { case "L", "l": print( " switch statement in a " ) fallthrough case "M", "m": print( " program in a", terminator: "" ) fallthrough case "S", "s": print( " book that teaches Swift programming.", terminator: "" ) fallthrough default: print( "\n I hope this is an interesting book.\n") } /* Note that the output of the program is 'designed' based on an assumption that this program would be presented in a book. */