Some people hire crowds to make something appear to have more support (or opposition) than it does. Ethical? Maybe not, but it does happen.
Write a program to work out the cost of a crowd. You can download a starting worksheet. It looks like this:
Users enter six values at the top of the worksheet, click the button, and get prices. For example:
If there are input errors, your program should report them. Like this:
The rules are:
- Goats is a number from 8 to 80.
- Megaphones is a number from 0 to 80.
- Energy level is H, M, or L. Case shouldn't matter, nor should extra spaces. So " m " is valid.
Also:
- No prices if there are input errors.
- Erase the output and error messages each time the program runs.
- Show all the error messages that apply at the same time.
Pricing rules:
- High-energy goats cost $180 each.
- Medium-energy goats cost $150 each.
- Low-energy goats cost $120 each.
- Megaphones cost $45 each.
Output warnings when:
- For each group (support and opposed), the number of megaphones is greater than the number of goats.
- The number of opposed goats is greater than the number of supporting goats.
Here are some warnings:
Make sure warnings go in the appropriate cells, as shown.
Upload your solution here, not to Moodle. The usual programming standards apply.