Last active
January 2, 2020 03:35
-
-
Save 40823102/e258ec1038576f30da81003363199f5e to your computer and use it in GitHub Desktop.
重量單位轉換程式
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IbtoKg(num ib){ | |
return ib*0.45; | |
} | |
KgtoIb(num kg){ | |
return kg*2.2; | |
} | |
main() { | |
var type; | |
int len; | |
var number; | |
List temp = ["25Kg", "30Ib", "56Ib", "14Kg", "68Ib", "198Kg"]; | |
for (var i in temp) { | |
len = i.length; | |
type = i[len-2]; | |
number = i.substring(0, len-2); | |
number = int.parse(number); | |
if (type == "I"){ | |
print(" $number Ib = ${IbtoKg(number).toStringAsFixed(2)} Kg"); | |
}else{ | |
print(" $number Kg = ${KgtoIb(number).toStringAsFixed(2)} Ib"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment