Project 1: Yondu Udonta
Problem Statement
Yondu Udonta and his crew of space pirates arrive at the Iron Lotus after several weeks of plundering the high seas. Since the crew has been in space for nearly six months, they are ready for a night of celebration. Yondu doesn’t want to divvy up the plunder just yet, so he gives each crew member other than himself and Peter Quill 3 units and sends them off to the Iron Lotus. (We’re keeping the units simple for purposes of the problem, even though 1 unit is about $2.33.)
After the crew has gone, he and Peter count what’s left and decide how to split it up among the crew. Yondu takes 13% plunder, which he transfers to a hidden bank account. Yondu gives Peter 11% of the remaining units, which Peter transfers to his account. The next morning, the remaining units are divided evenly among all of the crew, including Yondu and Quill. Little do they know that Yondu and Quill have already taken a cut. If the remaining treasure can’t be split evenly, the units left over are given to the Reaver’s Benevolent Fund (RBF).
-
Compute how many units each person gets and how how much goes to the RBF. Do not count the 3 coins each crew took into town as part of their total share, since they already spent them. Of course, you have to count those coins when you check your totals for correctness versus the total.
-
A unit 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 units, you could only give him 25 units, not 25.67 units. Warning: Always round down, NOT up. Simply drop the fractional part, but don’t lose any units from the overall total amount.
-
Prompt the user for two pieces of information: How many units the Reavers came into port with, and how many pirates are on the ship, including Yondu and Quill. The program should then calculate and display Yondu’s share, Peter’s share, the other crew member’s individual share, and the RBF Amount.
Directions
-
Develop your algorithm in detail before writing any code. Read the problem statement very closely several times to make sure you understand all the small details.
- Accept the assignment in GitHub by opening the Assignment Invitation URL link provided in your Canvas assignment.
- This video provides step-by-step directions for completing GitHub assignments.
- From inside your GitHub repository, click the Work in Repl.it button.
- You’ll need an upgraded repl.it account (video directions)
-
Open the
exercise.py
file in thesrc
directory, and begin coding your solution. -
Update the module docstring with your information.
- Test your program by running it several times with different input. Verify your algorithm is correct by checking the program output:
User input: Reavers |
User Input: Units |
Program Output: |
---|---|---|
20 | 1000 | Yondu’s share: 158 Peter’s share: 126 Crew: 36 RBF: 14 |
Anything other than a positive integer | Enter only positive integers for reavers and units. | |
Anything other than a positive integer | Enter only positive integers for reavers and units. | |
less than three | Not enough crew. | |
Less than or equal to 3 times the number of reavers | Not enough units. |
-
Format the user prompt and output exactly as shown in the example below:
How many Reavers: 20 How many units: 1000 Yondu's share: 158 Peter's share: 126 Crew: 36 RBF: 14
-
Click the Version Control icon in the left menu, type a memo in the What did you change text box, then click Commit & push
-
Navigate back to your GitHub repository, open the Actions tab, and check your program for accuracy.
- A green icon indicates your code passed all test cases. Congratulations!
- A red icon indicates your code needs to be revised and resubmitted.