Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Glibc
- var index: String?;
- while index != "4" {
- system("clear")
- print("--- KALKULATOR SWIFT ---")
- print("Wybiarz pole oraz obwod ktorej figury chcesz liczyc:")
- print("1. Kwadrat")
- print("2. Trojkat")
- print("3. Prostokat")
- print("4. Koniec")
- index = readLine()
- system("clear")
- switch index {
- case "1" :
- print("--- KWADRAT ---")
- print("Podaj a:")
- var a = readLine()
- let numA = Double(a!)
- print("Pole: \(Double(numA!) * Double(numA!))")
- print("Obwod: \(4 * Double(numA!))")
- a = readLine();
- break
- case "2" :
- print("--- TROJKAT ---")
- print("Podaj a:")
- var a = readLine()
- let numA = Double(a!)
- print("Podaj b:")
- let b = readLine()
- let numB = Double(b!)
- print("Podaj c:")
- let c = readLine()
- let numC = Double(c!)
- print("Pole: \(Double(numA!) * Double(numB!)/2)")
- print("Obwod: \(Double(numA!) + Double(numB!) + Double(numC!))")
- a = readLine();
- break
- case "3" :
- print("--- PROSTOKAT ---")
- print("Podaj a:")
- var a = readLine()
- let numA = Double(a!)
- print("Podaj b:")
- let b = readLine()
- let numB = Double(b!)
- print("Pole: \(Double(numA!) * Double(numB!))")
- print("Obwod: \(2 * Double(numA!) + 2 * Double(numB!))")
- a = readLine();
- break
- default:
- break
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement