Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var a:Double
- var b:Double
- print("Liczenie pola i obwodu figur")
- print("1. Kwadrat")
- print("2. Prostakat")
- print("3. Trojkat")
- print("4. Zakoncz program")
- print("Twoj wybor:")
- let choice = readLine()
- switch choice{
- case "1":
- print("Podaj bok a kwadratu")
- a = Double(readLine()!)
- print(square(sideA: a))
- case "2":
- print("Podaj bok a prostokata")
- a = Double(readLine()!)
- print("Podaj bok b prostokata")
- b = Double(readLine()!)
- print(rectangle(sideA: a, sideB: b))
- case "3":
- print("Podaj podstawe a trojkata")
- a = Double(readLine()!)
- print("Podaj wysokosc b trojkata")
- b = Double(readLine()!)
- print(triangle(sideA: a, sideB: b))
- default:
- print("Ta opcja nie istnieje!")
- }
- func square(sideA: Double) -> Double {
- let result = "Pole kwadratu = " + sideA*sideA + "Obwod kwadratu = " + sideA*4
- return result
- }
- func rectangle(sideA: Double, sideB: Double) -> Double {
- let result = "Pole prostokata = " + sideA*sideB + "Obwod prostokata = " + sideA*2+sideB*2
- return result
- }
- func triangle(sideA: Double, sideB: Double, sideC: Double) -> Double {
- let result = "Pole trojkata = " + (sideA*sideB)/2 + "Obwod trojkata = " + sideA+sideB+sideC
- return result
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement