Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.swift
- // new2
- //
- // Created by ios on 1/8/19.
- // Copyright © 2019 ios. All rights reserved.
- //
- import Foundation
- //print ("enter a number: ")
- //var number:String? = readLine()!
- //
- //for number in 0...Int(number!)!{
- //
- // print(number)
- //}
- //
- //print ("enter a number1: ")
- //
- //var n1:String? = readLine()!
- //print ("enter a number2: ")
- //var n2:String? = readLine()!
- //
- //let x = Int (n1!)!
- //let z = Int (n2!)!
- //for n1 in (x...z) {
- //
- // print(n1)
- //}
- //for i in 0...8 {
- //
- // for _ in 0...i {
- // print ("*", terminator: "")
- // }
- //print("")
- //}
- print ("enter a number1: ")
- var price:String? = readLine()!
- let x = Double (price!)!
- print("price before discount: \(price!)")
- switch x {
- case ...600:
- let y:Double = (Double (x) * 0.02)
- print ("price after discount \(x - y)")
- case 600...999:
- let y:Double = (Double (x) * 0.04)
- print ("price after discount \(x - y)")
- case 1000...1449:
- let y:Double = (Double (x) * 0.08)
- print ("price after discount \(x - y)")
- case 1500...1999:
- let y:Double = (Double (x) * 0.12)
- print ("price after discount \(x - y)")
- case 2000...:
- let y:Double = (Double (x) * 0.15)
- print ("price after discount \(x - y)")
- default:
- print ("enter PRICE")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement