Infinite number of solutions to puzzle

Assignment Help Basic Computer Science
Reference no: EM131381723

This is a exercise about Java. I do not how to start to write.

Here is a variant of a famous old puzzle published originally in The Saturday Evening Post , 1926, in a short story entitled "Coconuts," by Ben Ames Williams.

Five sailors, stranded on an island, spent their first day collecting coconuts. In the evening, they put all the coconuts into a single pile and went to sleep.

Sailor One, distrustful of his fellow sailors, woke up during the night, took one fifth of the coconuts, and went back to sleep. Then, a hungry monkey shimmied down a tree and took 1 coconut. A bit later, Sailor Two awoke and took a fifth of the remaining coconuts. Again, the monkey came down and took a coconut. Later, the third, fourth, and fifth sailors did likewise and the monkey took a coconut each time. In the morning, when the five sailors tried to divide the remaining coconuts into five equal piles, they had one coconut left, which they tossed to the ever-hungry monkey. How many coconuts were in the original pile?

There is an infinite number of solutions to this puzzle. Each solution is of the form: number of coconuts = 12495 + 15625 * a, where a=0,1,2,3. . . .

For example, if a=0, then the original number of coconuts is 12495 + 15625 * 0 = 12495; and if a=1 the number is 12495 + 15625 * 1 = 28120. Your job is to write a program that accepts a non-negative integer a (You can assume the user will always input only a non-negative integer), calculates the initial number of coconuts and displays how many coconuts each sailor takes, as well as how many they share in the morning.

Reference no: EM131381723

Questions Cloud

Network fundamental characteristics and components : Select an organization you are familiar with, or select one of the Virtual Organizations (Riordan Manufacturing or Kudler Foods), for your project. This project will continue throughout the coming weeks and build upon itself culminating in Week Fi..
Write appropriate hypotheses : Do these figures give evidence of a change in student attendance?
Describe the key characteristics of a whistleblower : Describe the key characteristics of a whistleblower, and briefly summarize one (1) researched instance of whistleblowing in one (1) publicly traded company within the last 3 years. Include the details of the issue that the whistleblower reported a..
Security challenges for system administrators : Bring Your Own Device created security challenges for system administrators. identify potential problem personal devices, share instances or examples of what makes them high risk, and provide potential solutions or advantages of a BYOD policy. you..
Infinite number of solutions to puzzle : There is an infinite number of solutions to this puzzle. Each solution is of the form: number of coconuts = 12495 + 15625 * a, where a=0,1,2,3. . . .
Initial steps in creating a security policy : Choose a company for this project and consider the initial steps in creating a security policy. Develop security goals and components that make up a quality Executive Summary.
Create a gui to display the structure : Read a data file, create the internal data structure, create a GUI to display the structure, and let the user search the structure. Sort the structure, use hash maps to create the structure more efficiently.
Describe the considerations for leading multicultural teams : BBA 3651:Assume that you have been tasked with preparing a cultural brief for an upcoming trip that will put you and your travel companions in touch with three different societal clusters. Choose three clusters other than the one in which you curr..
Neglect shear and moment considerations : Unless otherwise noted, the given loads are superimposed loads; neglect the beam weight; neglect shear and moment considerations.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Describe a problem involving relationships

Describe a problem involving relationships that you could solve by applying a function. Determine the steps for solving this problem.

  How you would divide the fields into different tables

How you would divide the fields into different tables so that all tables are fully normalized. This means no redundancy. Think about this one.

  Simple countdown for a webpage

You have been given a task to create a simple countdown for a webpage. Using JavaScript create a countdown time for the new year 2017. Attach necessary files and explain your code step-wise.

  Introduction to networking course

You have just completed 10 weeks of an introduction to networking course. Imagine you have been asked to create a one-day training course that highlights the important elements of what you have just learned within the past ten (10) weeks.

  Use a computer for multimedia

To use a computer for multimedia (moving video and sound), it is important to maximize the efficiency of the I/O. Assume that the blocks of a movie are stored consecutively on a CD-ROM. Describe the steps used to retrieve the blocks for use by the..

  Make a supply and demand curve for ipods

How to start the four step process to make a supply and demand curve for ipods?

  Evaluate the user interface of a website

Identify an e-commerce website whose interface has some design challenges -  There are some guiding principles that can help you as a systems analyst to develop interfaces that will create a positive experience for the user.

  Radius implementation

Suppose you are a Systems Administrator, and you have been tasked with implementing RADIUS to support authentication, authorization, and accounting in your organizations Windows network environment.

  The caption element provides caption for image true or false

The caption element provides a caption for the image in a figure element. True or False

  What information must be passed in order for the decoder

Given that the encoder and decoder have agreed on the algorithm, what information must be passed in order for the decoder to recover the source string?

  Consider the implications for private individuals

You are required to research and discuss how the "Right to be forgotten" ruling (C131/12) may affect the quality of information shared on the Internet. Build and publish a website to illustrate and draw out your findings.

  Change margins vertical alignment and font and font size

Change margins, vertical alignment, line spacing, and font and font size, and delete blank lines. Set tab stops using the ruler to line up information. Set tab stops and add leaders to create lines for users to fill in information.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd