Advertisement
miknik97

Swift - Calc

Feb 25th, 2020
1,289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.41 KB | None | 0 0
  1. import Glibc
  2.  
  3. var index: String?;
  4. while index != "4" {
  5.   system("clear")
  6.   print("--- KALKULATOR SWIFT ---")
  7.   print("Wybiarz pole oraz obwod ktorej figury chcesz liczyc:")
  8.   print("1. Kwadrat")
  9.   print("2. Trojkat")
  10.   print("3. Prostokat")
  11.   print("4. Koniec")
  12.   index = readLine()
  13.   system("clear")
  14.  
  15.   switch index {
  16.     case "1" :
  17.       print("--- KWADRAT ---")
  18.       print("Podaj a:")
  19.       var a = readLine()
  20.       let numA = Double(a!)
  21.       print("Pole: \(Double(numA!) * Double(numA!))")
  22.       print("Obwod: \(4 * Double(numA!))")
  23.       a = readLine();
  24.       break
  25.     case "2" :
  26.       print("--- TROJKAT ---")
  27.       print("Podaj a:")
  28.       var a = readLine()
  29.       let numA = Double(a!)
  30.       print("Podaj b:")
  31.       let b = readLine()
  32.       let numB = Double(b!)
  33.       print("Podaj c:")
  34.       let c = readLine()
  35.       let numC = Double(c!)
  36.       print("Pole: \(Double(numA!) * Double(numB!)/2)")
  37.       print("Obwod: \(Double(numA!) + Double(numB!) + Double(numC!))")
  38.       a = readLine();
  39.       break
  40.     case "3" :
  41.       print("--- PROSTOKAT ---")
  42.       print("Podaj a:")
  43.       var a = readLine()
  44.       let numA = Double(a!)
  45.       print("Podaj b:")
  46.       let b = readLine()
  47.       let numB = Double(b!)
  48.       print("Pole: \(Double(numA!) * Double(numB!))")
  49.       print("Obwod: \(2 * Double(numA!) + 2 * Double(numB!))")
  50.       a = readLine();
  51.       break
  52.     default:
  53.       break
  54.   }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement