// Whilesum.swift Copyright (c) Kari Laitinen // http://www.naturalprogramming.com // 2014-09-26 File created. // 2015-10-17 Last modification. import Foundation var integer_from_keyboard = -1 var sum_of_integers = 0 print( "\n This program calculates the sum of the integers" + "\n you type in from the keyboard. By entering a" + "\n zero you can terminate the program. \n" ) while integer_from_keyboard != 0 { print( String( format: " Current sum: %8d Enter an integer: ", sum_of_integers ), terminator: "" ) integer_from_keyboard = Int( readLine()! )! sum_of_integers = sum_of_integers + integer_from_keyboard } print( "\n" ) /* Compile and run this program in Terminal window with the command xcrun swift Whilesum.swift */