rangga_hrdme

KINDS OF FUNCTION 2

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