Libraryless. Click here for Pure Java version (1635L/11K/37K).
1 | !752 |
2 | |
3 | p{
|
4 | makeBot("Unit converter bot");
|
5 | } |
6 | |
7 | answer{
|
8 | if(matchStart("* * to *", s, m)){
|
9 | double num = Double.parseDouble(m.unq(0)); |
10 | S from = m.unq(1); |
11 | S to = m.unq(2); |
12 | if(from == "c" && to == "f"){
|
13 | Double result = (num * 1.8) + 32; |
14 | ret "" + result; |
15 | } |
16 | if(from == "f" && to == "c"){
|
17 | Double result = (num - 32) / 1.8; |
18 | ret "" + result; |
19 | } |
20 | if(from == "m"){
|
21 | if(to == "mm"){
|
22 | Double result = num * 1000; |
23 | ret "" + result; |
24 | } |
25 | if(to == "cm"){
|
26 | Double result = num * 100; |
27 | ret "" + result; |
28 | } |
29 | if(to == "dm"){
|
30 | Double result = num * 10; |
31 | ret "" + result; |
32 | } |
33 | if(to == "dam"){
|
34 | Double result = num / 10; |
35 | ret "" + result; |
36 | } |
37 | if(to == "hm"){
|
38 | Double result = num / 100; |
39 | ret "" + result; |
40 | } |
41 | if(to == "km"){
|
42 | Double result = num / 1000; |
43 | ret "" + result; |
44 | } |
45 | } |
46 | } |
47 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1002331 |
| Snippet name: | Unit converter bot |
| Eternal ID of this version: | #1002331/1 |
| Text MD5: | d6da1d5a0d83167a15168aff1127f8ba |
| Transpilation MD5: | 5a57ee2583adb63bcbaafb2576224094 |
| Author: | bgrgndz |
| Category: | |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-01-06 19:34:28 |
| Source code size: | 1005 bytes / 47 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 1204 / 2170 |
| Referenced in: | [show references] |