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. Jack doesn't want to divvy up the plunder just yet, so he gives each man in the crew other than himself and the first mate Mr. Gibbs 3 pieces of gold and sends them into town to celebrate. After the crew has gone, he and Gibbs count what's left and decide how to split it up among the crew. Jack takes 12% of the gold, which he counts out and hides in his cabin. Jack gives Gibbs 8% of the remaining gold, which Gibbs counts out and counts out and hides in his cabin. The next morning, the remaining gold is divided evenly among the members of the crew, including Jack and Gibbs. Little do they know that Cap'n Jack and Mr. Gibbs 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 Fund (PBF).
The problem is to compute how much gold each person gets and how how much goes to the PBF. 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, but don't lose any gold from the overall total amount.
Your program should work for any reasonable set of inputs. It should ask a user for two pieces of information:
The program should then split the gold and print out
Here's an example interaction showing user input and output:
Number of Pirates: 20 Number of gold coins: 1000 Jack's share: 151 Gibb's share: 104 Crew: 38 PBF: 7
*the code should be written in Python.
code:
# read number of pirates
n=int(input('Enter number of Pirates\n'))
# read number of coins
total=int(input('Enter number of Coins\n'))
temp=total
#each crew takes 3 coins
total=total-(n-2)*3
# jack's share
js=12*total//100
total=total-js
# gibbs share
gs=8*total//100
total=total-gs
# crew share
cs=total//(n)
# final jack's share
js=js+cs
# final gibb's share
gs=gs+cs
print("Jack's share:" ,js)
print("Gibb's share:" ,gs)
print("Crew :",cs)
print("PBF:",temp-js-gs-(cs+3)*(n-2))
screenshot
sample output
please upvote if it helped.Feel free to ask any query
Captain Jack and his crew of pirates arrive in Tortuga after several weeks of plundering the...
Actions that damage a company and its employees should be stamped out, everyone would agree. But should the people responsible be stamped out, too? HBR CASE STUDY The Reign of Zero Tolerance by Ben Gerson "Mr. Pemberton?" manager. The guards had radioed her that the "Yes, that's me," Simon replied distractedly, his back turned. target wasn't putting up much resistance. "Your personal belongings will be messen The two burly gentlemen who had suddenly gered to your home later today," Sallie...