@frozen
struct String
import Foundation
func calcBMI (weight : Double, height : Double ){
let bmi = weight / (height*height*0.0001)
let shortenedBmi = String(format : "%.1f", bmi)
switch bmi{
case 0.0..<18.5:
print("BMI:\(shortenedBmi),판정 : 저체중")
case 18.5..<25.0:
print("BMI:\(shortenedBmi),판정 : 정상")
case 25.0..<30.0:
print("BMI:\(shortenedBmi),판정 : 1단계 비만")
case 30.0..<40.0:
print("BMI:\(shortenedBmi),판정 : 2단계 비만")
default :
print("BMI:\(shortenedBmi),판정 : 3단게 비만")
}
}
calcBMI(weight: 70.0, height: 170.0)
import Foundation
class BMI {
var weight : Double
var height : Double
init(weight:Double, height:Double){
self.height = height
self.weight = weight
}
func calcBMI() -> Double{
return weight/(height*height*0.0001)
}
}
var han = BMI(weight:62.5, height:172.3)
print(han.calcBMI())
import Foundation
class BMI {
var weight : Double
var height : Double
init(weight:Double, height:Double){
self.height = height
self.weight = weight
}
func calcBMI() -> String {
let bmi=weight/(height*height*0.0001)// kg/m*m
let shortenedBmi = String(format: "%.1f", bmi)
var body =
""
if bmi >= 40{
body =
"3단계 비만"
} else if bmi >= 30 && bmi < 40 {
body =
"2단계 비만"
} else if bmi >= 25 && bmi < 30 {
body =
"1단계 비만"
} else if bmi >= 18.5 && bmi < 25 {
body =
"정상"
} else {
body =
"저체중"
}
return "BMI:\(shortenedBmi), 판정:\(body)"
}
}
var han = BMI(weight:62.5, height:172.3)
print(han.calcBMI())

//소스에서 변경하는 방법: button도 아웃렛 만들어서
button.clipsToBounds = true
button.layer.cornerRadius = 0.5 * button.bounds.size.height

다른 여러가지의 키보드들도 존재한다.