Karla Krab is the bomb in the crab (and lobster) party scene. You want to see and be seen (and you're a crab (or lobster))? Go to one of Karla's legendary mix-it-up-like-a-blender-on-acid raves.
Write a VBA program to help Karla plan a party. You can download a starting worksheet.
Karla has lost money in the past, when fewer crustaceans turned up than she had planned for. The room was too big (and expensive), and she had too much offal left over (crabs (and lobsters) eat offal). She wants your program to predict the effect on profits, if planned and actual attendance are different.
Your worksheet should start like this:
The user fills in six values, above the Run button. Each one must be numeric, and 0 or more. If there's invalid data, show an appropriate error message, and stop the program. Like this:
Crab ticket price is the cost of one crab ticket to the party, in clams. Lobster ticket price is the same, for lobsters. Planned attendance is the number of crabs (and lobsters) the party is planned for. Actual attendance is the number who show up.
Cost has two parts: shack rental, and offal cost. Shack rental depends on total (crabs plus lobsters) planned attendance. If there are fewer than 100, Karla can rent the small shack, for 1,100 clams. If planned attendance is 100 or more, but less than 300, Karla can rent the medium shack, for 1,500 clams. If planned attendance is 300 or more, but no more than 500, Karla can rent the large shack, for 1,900 clams. If planned attendance is more than 500, then show an error message, something like "Sorry, the total actual attendance must be 500 or less.", and stop the program.
Offal costs 10 clams for each crab, and 15 clams for each lobster. Total offal cost is based on planned attendance.
Revenue is based on actual crab (and lobster) attendance. The user has typed in the ticket prices.
Example:
Requirement: Use the Cells() function only in the input and output parts of your programs. Use variables in the processing. So don't do something like this:
Cells(22, 33) = Cells(34, 23) * Cells(23, 44)
Instead, put the data into variables during input. Processing would just use variables, like this:
aVariable = anotherVariable * yetAnotherVariable
In output, put variables into cells.
Hints:
- Copy-and-paste is your friend.
- Write code for one input/validation first, and then test it, before you copy it.
- Don't worry about the capacity of the room being exceeded.
- You can use Single for all numeric variables, if you like.
Upload your workbook.
(If you were logged in as a student, you could submit an exercise solution, and get some feedback.)