當商品價錢小於等於10塊時,小費10% 當商品大於10塊,小於等於20塊時,小費15% 當商品大於20塊時,小費20%。計算商品加上小費後的價格

//宣告變數商品價格price
var price = 15.0
//當商品價格<10元,小費10%
if price < 10.0 {
   price = price * 1.1
}
//當賞品價格<20元,小費15%
else if price < 20.0 {
        price = price * 1.15
}
//當商品價格>20%,小費20%
else {
       price = price * 1.2
}
//印出價格
price
A single golf clap? Or a long standing ovation?

By clapping more or less, you can signal to us which stories really stand out.