Advertisement
rangga_hrdme

KINDS OF FUNCTION 3

Apr 26th, 2021
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.37 KB | None | 0 0
  1. import java.util.Scanner
  2.  
  3. var asset: Double? = null
  4. var estimation: Double? = null
  5. var start: Int? = null
  6. var end: Int? = null
  7. var texts = Scanner(System.`in`)
  8.  
  9. fun main() {
  10.  
  11.     println("Depreciation : Straight Line Method")
  12.     print("Cost of Bought: ")
  13.     asset = texts.nextDouble()
  14.     println("Period of Depreciation(Year): ")
  15.     print("Begin of Year (Integer): ")
  16.     start = texts.nextInt()
  17.     print("End of Year (Integer): ")
  18.     end = texts.nextInt()
  19.     print("Residual value(Float): ")
  20.     estimation = texts.nextDouble()
  21.     StraightLine(asset!!, start!!, end!!, estimation!!)
  22. }
  23.  
  24. fun StraightLine(asset: Double, start: Int, end: Int, estimation: Double): Double {
  25.     if (asset > 0 && start > 0 && end > 0) {
  26.         var depreciation: Double = ((asset - estimation) / end)
  27.         println(" Depreciation/ Year : ${depreciation.toLong()}")
  28.         println("|Year|      Amount   -   Accummulation  =    Resid  |")
  29.     } else {
  30.         print(" Minimal Integer: 1")
  31.     }
  32.  
  33.     var accummulation: Double = (start.toDouble() / end.toDouble()) * (asset - estimation)
  34.     var resid: Double = asset - accummulation
  35.     println("$start   ${asset.toLong()} - ${accummulation.toLong()} = ${resid.toLong()}")
  36.     return resid
  37. }
  38. // METHOD(FUNCTION HAS RETURN)
  39. // Pray 4 Uyghur: https://bylinetimes.com/2020/08/24/death-is-everywhere-millions-more-uyghurs-missing/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement