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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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