At the completion of this project, you will have created an application that
Captain Jack and his crew of pirates arrive in Tortuga after several weeks of plundering the high seas. Since the crew has been at sea for nearly a month, they are ready for a night of celebration. Captain Jack doesn't want to divvy up the treasure just yet, so he gives each man in the crew (except for himself and the first mate) 3 pieces of gold and sends them into town to celebrate. After the crew has gone he and the first mate count what's left and decide how to split it up among the crew. Captain Jack decides that he'll take 12% of the gold. He counts out his gold and hides it in his cabin. The Captain agrees to give the first mate 8% of the remaining gold. The first mate counts out his coins and hides it in his cabin. The next morning, the gold that is left is divided evenly among the members of the crew, including Captain Jack and the First Mate. Little do they know that Cap'n Jack and the first mate have already taken a cut. If the remaining treasure can't be split evenly, the bits that are left over are given to the Pirate's Benevolent Association.
The problem is to compute how much gold each person gets, and if any, how much goes to the Pirate's Benevolent Association. Keep in mind that a piece of gold cannot be split, so if some calculation yields a number that contains a fractional part, you can only give that person the integer part of the value. For example, if your program computed the captain's share as 25.67 pieces of gold, you could only give him 25 pieces of gold, not 25.67 pieces of gold. Warning, when you do any calculations do not round up. Simply drop the fractional part.
You should design your own interface for this problem. It need not look like the one shown here, but it must contain the required information.
Your interface should have a menu strip with a menu item for exiting the application and one for showing your about box.
The interface should also have the following Text Boxes, appropriately labeled:
Finally, add a button that will cause these calculations to be performed.
Your program should ask the user for two pieces of information:
Your program should work for any reasonable set of inputs. Here is an example of what your program should produce.
With 20 pirates and 1000 pieces of gold:
|Captain Jack||113 gold coins (151 if you count the 38 everyone in the crew gets)|
|First Mate||66 gold coins (104 if you count the 38 coins everyone in the crew gets)|
|The Crew||38 gold coins each (don't count the 3 coins each took into town)|
|The PBA||7 gold coins|
Create Event handlers for the exit menu item, the about menu item, and for the button. Before you fill in the code for the button's event handler, write the pseudo-code that you need to explain how the calculations to divide up the gold should work. Put this pseudo-code inside the curly braces for the button's event handler. This is where most of the action will take place in your program. Now fill in the actual code statements that do what your pseudo-code asked for.
Format and document your code in accordance with the course style guidelines. Include a file prologue identifying you as the author. Be sure that you have complete method prologues on each method. Be sure that you have no magic numbers in your code. Submit your project using the instructions outlined in the Course Syllabus, Programming Projects section.
Place your complete project folder into
a zip file and name the zip file
proj_02_your-initials_V1.0.zip. For example, I would name my file proj_02_RKD_V1.0.zip. Submit this assignment as Project #2 on Canvas.
|Description||Points possible||Your points|
Project meets the following guidelines:
Your program provides a graphical user interface similar to the one shown. It contains working Exit and and About menu items. Your interface us inituitive and easy to use.
When the user fills in the number of pirates and the number of gold pieces, and clicks on the button, your program correctly divides the gold, according to the specifications.
Early bonus (+3 pts) or late penalty (20%/day)
You can get an executable that runs correctly here!