Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- Online Swift Compiler.
- Code, Compile, Run and Debug Swift script online.
- Write your code in this editor and press "Run" button to execute it.
- */
- func
- howOld ()->
- String
- {
- let currentYear = 2022;
- print ("Podaj rok swojego urodzenia: ")
- let birthDateString:String! = readLine ();
- let yourAge:Int? = currentYear - Int (birthDateString)!;
- return "Masz \(yourAge!) lat.";
- }
- func
- circleProps ()
- {
- print ("Podaj promien kola: ");
- let pi = 3.14;
- let radius:String! = readLine ();
- let circumference:Double = 2 * pi * Double (radius)!;
- let field = pi * Double (radius)! * Double (radius)!;
- print( " Promien kola: \(radius!)\n", "Obwod kola: \(circumference)\n",
- "Pole kola: \(field)")
- }
- func cuboid() -> String {
- print("Podaj dlugosc boku szescianu: ");
- let cubeSide: String! = readLine();
- let cubeSideFloat: Float = Float(cubeSide)!;
- let volume: Float = cubeSideFloat * cubeSideFloat * cubeSideFloat;
- let totalArea: Float = cubeSideFloat * cubeSideFloat * 6;
- return "Szescian ma objetosc \(volume) oraz pole calkowite \(totalArea)";
- }
- func boardPrice() -> Float {
- print("Podaj dlugosc pokoju: ");
- let a: String! = readLine();
- print("Podaj szerokosc pokoju: ");
- let b: String! = readLine();
- print("Podaj dlugosc korytarza: ");
- let z: String! = readLine();
- print("Podaj szerokosc drzwi: ");
- let s: String! = readLine()
- print("Podaj cene listwy: ");
- let boardMeterPrice: String! = readLine();
- let boardLength: Float = Float(a)! * 2 + Float(b)! * 3 + Float(z)! * 2 - Float(s)!;
- let boardPrice = Float(boardMeterPrice)! * boardLength;
- return boardPrice;
- }
- func aritAvg() -> Float {
- let aritAvg = (Float.random(in: 1...9) + Float.random(in: 1...9) + Float.random(in: 1...9)) / 3;
- return aritAvg;
- }
- func weigAvg() -> Float {
- print("Podaj ocene: ");
- let gr1: String! = readLine();
- print("Podaj jej wage: ");
- let gr1w: String! = readLine();
- print("Podaj ocene: ");
- let gr2: String! = readLine();
- print("Podaj jej wage: ");
- let gr2w: String! = readLine();
- print("Podaj ocene: ");
- let gr3: String! = readLine();
- print("Podaj jej wage: ");
- let gr3w: String! = readLine();
- let result = (Float(gr1)! * Float(gr1w)! + Float(gr2)! * Float(gr2w)! +
- Float(gr3)! * Float(gr3w)!) / (Float(gr1w)! + Float(gr2w)! +
- Float(gr3w)!);
- return result;
- }
- print(weigAvg());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement