Question
The only way Santa can hit his production targets is to enslave elves. Currently, he has 16,384 slaves. To keep order, Santa formed the Greater
The only way Santa can hit his production targets is to enslave elves. Currently, he has 16,384 slaves. To keep order, Santa formed the Greater Elf Security and Tactical Police, aka the Gestapo. The Gestapo has 512 overseers, 16 captains, and General Huggy Buns, the head of the force.
Every year, Santa resupplies the Gestapo with uniforms, whips, and tasers. Every Gestapo member gets one new uniform every year, except for General Huggy Buns, who gets three.
The number of whips and tasers Santa buys depends on the unrest forecast (UF). If UF is low, heres how many items each Gestapo member gets:
Overseers | Captains | General | |
Whips | 1 | 3 | 5 |
Tasers | 1 | 2 | 4 |
If UF is moderate, heres how many items each Gestapo member gets:
Overseers | Captains | General | |
Whips | 2 | 5 | 9 |
Tasers | 2 | 4 | 8 |
If UF is high, heres how many items each Gestapo member gets:
Overseers | Captains | General | |
Whips | 3 | 8 | 16 |
Tasers | 3 | 7 | 15 |
This code gives unit prices for every item Santa buys:
uniformOverseerUnitPrice = 129.5
uniformCaptainUnitPrice = 289.25
uniformGeneralUnitPrice = 1295.5
whipUnitPrice = 87.5
taserUnitPrice = 429
Write a program that takes the UF as input, and shows counts and totals, as shown in this example:
Hints:
Divide your code into input, processing, and output.
Try doing just the uniforms to start with. Get that right, then add the other stuff.
Do everything with VBA, of course. No formulas in the worksheet. Here is my code now, it's incorrect for some reason I can't figure out.
Option Explicit
Private Sub CommandButton1_Click() 'Declare variables Dim UF As String Dim unNum As Integer Dim whipNum As Long Dim tasNum As Long Dim unCost As Long Dim whipCost As Long Dim tasCost As Long Dim totNum As Integer Dim totCost As Long
'Get data
UF = LCase(Cells(3, 2)) If UF "low" And UF "moderate" And UF "high" Then MsgBox "you must enter low moderate or high" End End If If UF = "low" Then whipNum = 555 tasNum = 584
ElseIf UF = "moderate" Then whipNum = 1113 tasNum = 1096 ElseIf UF = "high" Then whipNum = 1680 tasNum = 1663 End If
'compute unNum = 531 unCost = 74818.5 tasCost = 429 * tasNum whipCost = 87.5 * whipNum totNum = whipNum + unNum + tasNum totCost = unCost + tasCost + whipCost
'output Cells(7, 2) = unNum Cells(8, 2) = whipNum Cells(9, 2) = tasNum Cells(11, 2) = totNum Cells(7, 3) = unCost Cells(8, 3) = whipCost Cells(9, 3) = tasCost Cells(11, 3) = totCost
End Sub
SAMPLE:
2 1 Santa's security purchase 3 UF 4 low, moderate or high 5 6 7 Uniforms 74818.5 8 Whips 9 Tasers 10 11 Total ow Run Number Cost 65 49437.5 548 235092 1644359348 2 1 Santa's security purchase 3 UF 4 low, moderate or high 5 6 7 Uniforms 74818.5 8 Whips 9 Tasers 10 11 Total ow Run Number Cost 65 49437.5 548 235092 1644359348Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started