-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathTask.kt
More file actions
51 lines (46 loc) · 1.16 KB
/
Task.kt
File metadata and controls
51 lines (46 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import com.faangx.ktp.basics.ProfitLossCalculatorMiniApp
import kotlin.math.roundToInt
fun getSp1(cp: Int, pl: Int): Int {
return cp*(100+pl)/100
}
fun getSp2(cp: Int, absPL: Int): Int {
return cp + absPL
}
fun getCp1(sp: Int, pl: Int): Int {
return sp * 100 / (100 + pl)
}
fun getCp2(sp: Int, absPL: Int): Int {
return sp - absPL
}
fun getPl1(cp: Int, sp: Int): Int {
return ((sp - cp).toFloat() / cp * 100).roundToInt()
}
fun getPl2(cp: Int, absPL: Int): Int {
return (absPL.toFloat() / cp * 100).roundToInt()
}
fun getPl3(sp: Int, absPL: Int): Int {
return (absPL.toFloat() / (sp - absPL) * 100).roundToInt()
}
fun getAbsPL1(cp: Int, sp: Int): Int {
return sp - cp
}
fun getAbsPL2(cp: Int, pl: Int): Int {
return cp * pl / 100
}
fun getAbsPL3(sp: Int, pl: Int): Int {
return sp * pl / (100 + pl)
}
fun main() {
ProfitLossCalculatorMiniApp(
getSp1 = ::getSp1,
getSp2 = ::getSp2,
getCp1 = ::getCp1,
getCp2 = ::getCp2,
getPl1 = ::getPl1,
getPl2 = ::getPl2,
getPl3 = ::getPl3,
getAbsPL1 = ::getAbsPL1,
getAbsPL2 = ::getAbsPL2,
getAbsPL3 = ::getAbsPL3,
)
}