oatm7

Assignment 2

Mar 1st, 2022 (edited)
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #file: daily_needs_store.ps1
  2. #
  3. Write-Host ("`n{0,29}" -f "Affordable Daily Needs")
  4. Write-Host "This Program will prompt for 10 items."
  5. Write-Host "Enter quantity of each item purchased."
  6.  
  7. $TaxRate = 8.25
  8.  
  9. [float]$breadCount = Read-Host ("{0,-45}" -f "How many loaves of Bread (`$1.75 each)")
  10. [float]$milkCount = Read-Host ("{0,-45}" -f "How many Gallons of Milk (`$3.29 each)")
  11. [float]$chipsCount = Read-Host ("{0,-45}" -f "How many Bags of Chips (`$4.19 each)")
  12. [float]$potatoesCount = Read-Host ("{0,-45}" -f "How many Pounds of Potatoes (`$1.49 each)")
  13. [float]$bananasCount = Read-Host ("{0,-45}" -f "How many Pounds of Bananas (`$0.49 each)")
  14. [float]$beefCount = Read-Host ("{0,-45}" -f "How many Pounds of Beef (`$5.29 each)   ")
  15. [float]$tomatoesCount = Read-Host ("{0,-45}" -f "How many Pounds of Tomatoes (`$0.99 each)")
  16. [float]$applesCount = Read-Host ("{0,-45}" -f "How many Pounds of Apples (`$1.29 each)")
  17. [float]$batteriesCount = Read-Host ("{0,-45}" -f "How many 2-packs of AA Batteries (`$2.39 each)")
  18. [float]$vitaminCount = Read-Host ("{0,-45}" -f "How many Bottles of Vitamin (`$4.89 each)")
  19.  
  20. Write-Host ("{0,-50}" -f "===================================")
  21. Write-Host ("{0,29}" -f "Affordable Daily Needs")
  22. Write-Host ("{0,28}" -f "4715 San Pedro Avenue")
  23. Write-Host ("{0,29}" -f "San Antonio, TX 78217")
  24. Write-Host ("{0,27}" -f "Phone: 210-128-1919")
  25. Write-Host ("{0,-50}" -f "-----------------------------------")
  26.  
  27. [float]$total = 0.0;
  28. [float]$totalTax = 0.0;
  29. [float]$subTotal = 0.0;
  30.  
  31. $breadCost = $breadCount * 1.75
  32. $subTotal = $subTotal + $breadCost
  33.  
  34. $milkCost = $milkCount * 3.29
  35. $subTotal = $subTotal + $milkCost
  36.  
  37. $chipsCost = $chipsCount * 4.19
  38. $subTotal = $subTotal + $chipsCost
  39.  
  40. $potatoesCost = $potatoesCount * 1.49
  41. $subTotal = $subTotal + $potatoesCost
  42.  
  43. $bananasCost = $bananasCount * 0.49
  44. $subTotal = $subTotal + $bananasCost
  45.  
  46. $beefCost = $beefCount * 5.29
  47. $subTotal = $subTotal + $beefCost
  48.  
  49. $tomatoesCost = $tomatoesCount * 0.99
  50. $subTotal = $subTotal + $tomatoesCost
  51.  
  52. $applesCost = $applesCount * 1.29
  53. $subTotal = $subTotal + $applesCost
  54.  
  55. $batteriesCost = $batteriesCount * 2.39
  56. $subTotal = $subTotal + $batteriesCost
  57. $totalTax = $totalTax + ($batteriesCost * (1 + ($TaxRate/100)) - $batteriesCost)
  58.  
  59. $vitaminCost = $vitaminCount * 4.89
  60. $subTotal = $subTotal + $vitaminCost
  61. $totalTax = $totalTax + ($vitaminCost * (1 + ($TaxRate/100)) - $vitaminCost)
  62.  
  63. $total = $subTotal + $totalTax
  64.  
  65.  
  66. Write-Host ("{0,-10} {1,4} {2,11} {3,6}" -f "Item", "Qty", "Price/Unit", "Cost" )
  67. Write-Host ("{0,-50}" -f  "-----------------------------------")
  68. Write-Host ("{0,-10} {1,4:N1} {2,9} {3,8:N2}" -f "Bread", $breadCount, "`$1.75", $breadCost )
  69. Write-Host ("{0,-10} {1,4:N1} {2,9} {3,8:N2}" -f "Milk", $milkCount, "`$3.29", $milkCost )
  70. Write-Host ("{0,-10} {1,4:N1} {2,9} {3,8:N2}" -f "Chips", $chipsCount, "`$4.19", $chipsCost )
  71. Write-Host ("{0,-10} {1,4:N1} {2,9} {3,8:N2}" -f "Potatoes", $potatoesCount, "`$1.49", $potatoesCost )
  72. Write-Host ("{0,-10} {1,4:N1} {2,9} {3,8:N2}" -f "Beef", $beefCount, "`$5.29", $beefCost )
  73. Write-Host ("{0,-10} {1,4:N1} {2,9} {3,8:N2}" -f "Tomatoes", $tomatoesCount, "`$0.99", $tomatoesCost )
  74. Write-Host ("{0,-10} {1,4:N1} {2,9} {3,8:N2}" -f "Apples", $applesCount, "`$1.29", $applesCost )
  75. Write-Host ("{0,-10} {1,4:N1} {2,9} {3,8:N2}" -f "Batteries", $batteriesCount, "`$2.39", $batteriesCost )
  76. Write-Host ("{0,-10} {1,4:N1} {2,9} {3,8:N2}" -f "Vitamins", $vitaminCount, "`$4.89", $vitaminCost )
  77. Write-Host ("{0,-50}" -f "-----------------------------------")
  78. Write-Host ("{0,-10} {1,23:c2}" -f "Subtotal", $subTotal)
  79. Write-Host ("{0,-10} {1,22:c2}" -f "Tax `@ 8.25`%", $totalTax)
  80. Write-Host ("{0,-50}" -f "-----------------------------------")
  81. Write-Host ("{0,-10} {1,23:c2}" -f "Total", $total)
  82. Write-Host ("{0,-50}" -f"===================================")
  83. Write-Host "Sales Clerk: John Doe"
  84. Write-Host "Counter#: 7"
  85. Write-Host "Date:"(Get-Date)
Add Comment
Please, Sign In to add comment