'Make a class have function with 3 parameter (int,string,double ) with return value int in Kotlin
fun main() {
val thr = THR()
thr.kotlin()
thr.hitungthr(5000000, "1", 1.5)
}
class THR {
fun kotlin() {
println("Perhitungan THR")
}
fun hitungthr (gajipokok: Int, masakerja: String, jumlahthr: Double): Int {
var MasaKerja = masakerja.toInt()
var JumlahTHR = jumlahthr.toInt()
var hasil = gajipokok * MasaKerja * JumlahTHR
return hasil
}
}
when the program is run, only the display "Perhitungan THR" appears. The second function does not appear when the program is run.
Solution 1:[1]
You need to print the value returned by the function hitungthr
fun main() {
val thr = THR()
thr.kotlin()
print(thr.hitungthr(5000000, "1", 1.5))
}
Try to add print() in your main() function and try it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Anirban Bakshi |
