Advertisement
RashedBQ

Green shop

Jul 13th, 2021
72
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fun main(args: Array<String>) {
  2.  
  3.  
  4.     var branch = arrayListOf<Double>()
  5.     var item = arrayListOf<String>()
  6.  
  7.     var no =1
  8.     var sum =0.0
  9.  
  10.  
  11.     println("Enter Number branch ")
  12.     var bra = readLine()!!.toInt()
  13.  
  14.     println("Enter the number of purchases")
  15.     var items = readLine()!!.toInt()
  16.  
  17.     for (i in 1..items)
  18.     {
  19.  
  20.  
  21.         println("Enter the total value "+no)
  22.         branch[i]= readLine()!!.toDouble()
  23.         sum+=branch[i]
  24.         no++
  25.  
  26.     }
  27.  
  28.  
  29.     when(bra) {
  30.         1 -> {
  31.  
  32.  
  33.  
  34.  
  35.  
  36.             var dec =sum- sum *.10
  37.  
  38.             if (sum >= 100)
  39.             {
  40.                 for (i in 1..items)
  41.                 {
  42.                     println("Item "+item[i]+" | "+"Price "+branch[i])
  43.  
  44.                 }
  45.                 println( )
  46.                 println("Total invoice before discount $sum")
  47.                 println("Total invoice after discount $dec")
  48.                 var tax=tax(sum)
  49.                 println("Total invoice after Tax $tax")
  50.                 println( )
  51.  
  52.             }
  53.  
  54.             else println("Total invoice before discount $sum")
  55.             var tax=tax(sum)
  56.             println("Total invoice after Tax $tax")
  57.  
  58.  
  59.  
  60.         }
  61.         2 -> {
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.             for (i in 0..items)
  69.             {
  70.                 println("Item "+item[i]+" | "+"Price "+branch[i])
  71.  
  72.             }
  73.             println( )
  74.             println("Total invoice  $sum")
  75.  
  76.         }
  77.         3 -> {
  78.  
  79.  
  80.  
  81.  
  82.  
  83.             var dec = sum - 50
  84.  
  85.             if (sum > 500)
  86.             {
  87.                 for (i in 0..items)
  88.                 {
  89.                     println("Item "+item[i]+" | "+"Price "+branch[i])
  90.  
  91.                 }
  92.                 println( )
  93.                 println("Total invoice before discount $sum")
  94.                 println("Total invoice after discount $dec")
  95.                 var tax=tax(sum)
  96.                 println("Total invoice after Tax $tax")
  97.  
  98.             }
  99.  
  100.             else println("Total invoice before discount $sum")
  101.             var tax=tax(sum)
  102.             println("Total invoice after Tax $tax")
  103.         }
  104.     }
  105.  
  106. }
  107. fun tax(x: Double) : Double {
  108.     return x*.15
  109. }
Advertisement
RAW Paste Data Copied
Advertisement