Skip to content

Instantly share code, notes, and snippets.

@LOCOSP
Created October 15, 2018 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LOCOSP/e9f49c0af8f362e9e6efd941748d2296 to your computer and use it in GitHub Desktop.
Save LOCOSP/e9f49c0af8f362e9e6efd941748d2296 to your computer and use it in GitHub Desktop.
Swift Playground function
import Foundation
var wartoscTowaru: Float = 13
var rabat:Int = 10
func obliczRabat ( wartoscTowaru : Float, wysokoscRabatu : Int ) -> String {
let wartoscRabatu: Float = wartoscTowaru * Float(rabat) / 100
let formatWartoscRabatu = String(format: "%.2f", wartoscRabatu)
let kwotaPoRabacie = wartoscTowaru - wartoscRabatu
let formatKwotaPoRabacie = String(format: "%.2f", kwotaPoRabacie)
print("Wartość rabatu przy zniżce \(rabat)% wynosi: \(formatWartoscRabatu) PLN")
print("Kwota do zapłaty po rabacie: \(formatKwotaPoRabacie) PLN")
print (formatKwotaPoRabacie)
return formatKwotaPoRabacie
}
obliczRabat ( wartoscTowaru : wartoscTowaru, wysokoscRabatu : rabat)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment