Advertisement
RashedBQ

GreenFlag +

Jul 26th, 2021
77
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fun main(args: Array<String>) {
  2.  
  3.     var item =HashMap<Int,String>()
  4.     var sum =0.0
  5.  
  6.  
  7.     println("Enter Number Branch")
  8.     var branch = readLine()!!.toInt()
  9.  
  10.  
  11.     println ("Enter Number items")
  12.     var num = readLine()!!.toInt()
  13.     var value = Array<Double>(num){0.0}
  14.  
  15.  
  16.  
  17.  
  18.     var No =1
  19.     if (num != 0) {
  20.         for (i in 0 until value.size)
  21.         {
  22.             println("Enter Name of item "+No)
  23.             item.put(i, readLine()!!)
  24.  
  25.             println("Enter the price of the "+item.get(i))
  26.             value[i] = readLine()!!.toDouble()
  27.             sum+=value[i]
  28.             No++
  29.  
  30.         }
  31.  
  32.  
  33.     }
  34.  
  35.     when(branch){
  36.         1 -> {
  37.             if (sum >= 100)
  38.             {
  39.                 println("Put the discount rate")
  40.                 var dec = readLine()!!.toDouble()
  41.                 sum-sum*dec
  42.                 println("Total invoice Before discount $sum")
  43.                 println("Total invoice After discount $dec")
  44.                 var tax=tax(sum)
  45.                 println("Total invoice after Tax $tax")
  46.             }
  47.             else {
  48.                 println("Total invoice  $sum")
  49.                 var tax=tax(sum)
  50.                 println("Total invoice after Tax $tax")}
  51.         }
  52.         2 -> {
  53.             println("Total invoice  $sum")
  54.         }
  55.         3 -> {
  56.             println("Put the discount amount")
  57.             var dec50 = readLine()!!.toDouble()
  58.             sum - dec50
  59.             if (sum >= 500)
  60.             {
  61.  
  62.                 println("Total invoice Before discount $sum")
  63.                 println("Total invoice After discount $dec50")
  64.                 var tax=tax(sum)
  65.                 println("Total invoice after Tax $tax")
  66.             }
  67.             else {
  68.                 println("Total invoice  $sum")
  69.                 var tax=tax(sum)
  70.                 println("Total invoice after Tax $tax")}
  71.         }
  72.     }
  73.  
  74.         println("-----------GreenFlag-------------")
  75.     for (i in  value.size-1 downTo 0)
  76.     {
  77.         print("Item -- > "+item.get(i))
  78.         print(" | ")
  79.         println("Price -- > "+value[i])
  80.     }
  81.  
  82.  
  83.  
  84. }
  85.  
  86. fun tax(x: Double) : Double {
  87.  
  88.     return x*.15
  89. }
Advertisement
RAW Paste Data Copied
Advertisement