Question
Please program in JAVA ONLY The Puzzle: Five hardworking squirrels and a lazy chipmunk live in a nice yard. The five squirrels decide to work
Please program in JAVA ONLY
The Puzzle:
Five hardworking squirrels and a lazy chipmunk live in a nice yard. The five squirrels decide to work together collecting nuts and put them in a pile, they agree to work all day and then evenly divide the pile in the morning. After an exhausting day of collecting the squirrels all fall asleep. The chipmunk sleeps all day and wakes up as the squirrels are falling asleep.
Squirrel 1 wakes up in the night and decides that he does not trust the other squirrels so he divides the pile into 5 even piles. Squirrel 1 takes one of the five piles of nuts and hides them. He puts the remaining nuts into one pile, gives one nut from that pile to the chipmunk and goes back to sleep.
Squirrel 2 wakes up in the night and decides that she does not trust the other squirrels so she divides the pile into 5 even piles. Squirrel 2 takes one of the five piles of nuts and hides them. She puts the remaining nuts into one pile, gives one nut from that pile to the chipmunk and goes back to sleep.
Squirrel 3 wakes up in the night and decides that he does not trust the other squirrels so he divides the pile into 5 even piles. Squirrel 3 takes one of the five piles of nuts and hides them. He puts the remaining nuts into one pile, gives one nut from that pile to the chipmunk and goes back to sleep.
Squirrel 4 wakes up in the night and decides that she does not trust the other squirrels so she divides the pile into 5 even piles. Squirrel 4 takes one of the five piles of nuts and hides them. She puts the remaining nuts into one pile, gives one nut from that pile to the chipmunk and goes back to sleep.
Squirrel 5 wakes up in the night and decides that he does not trust the other squirrels so he divides the pile into 5 even piles. Squirrel 5 takes one of the five piles of nuts and hides them. He puts the remaining nuts into one pile, gives one nut from that pile to the chipmunk and goes back to sleep.
In the morning the squirrels wake up. They all notice that the pile is smaller but dont say anything because they have all taken from the pile and dont want the others to notice that it is smaller (each one thinks she/he is the only one who took from the pile during the night). The squirrels divide the pile into 5 even piles finding that they have one nut left over which they throw to the chipmunk. The squirrels go on their separate ways. The chipmunk goes to sleep.
Requirements:
1. You are to get from the user a positive whole number and save it to a variable of type int, name that variable n.
2. You are to calculate and print to the screen the number of nuts in the original pile. There are an infinite number of solutions to the number of nuts in the original pile. Every solution takes the form (where n is the number entered by the user):
number of nuts in the original pile = 12495 + 15625 * n
3. You are to calculate and print to the screen the following:
The initial number of nuts
The number of nuts that Squirrel 1 took during the night
The number of nuts that the chipmunk got during the night
The number of nuts that Squirrel 2 took during the night
The number of nuts that the chipmunk got during the night
The number of nuts that Squirrel 3 took during the night
The number of nuts that the chipmunk got during the night
The number of nuts that Squirrel 4 took during the night
The number of nuts that the chipmunk got during the night
The number of nuts that Squirrel 5 took during the night
The number of nuts that the chipmunk got during the night
The number of nuts in the pile in the morning
The number of nuts each squirrel got in the morning
The number of nuts the chipmunk got in the morning
Test Data and Expected Form of Output to Help You:
Please enter a positive int:
0
The number entered by the user: 0
The initial number of nuts is: 12495
Squirrel 1 gets 2499 nuts during the night, the chipmunk gets 1.
Squirrel 2 gets 1999 nuts during the night, the chipmunk gets 1.
Squirrel 3 gets 1599 nuts during the night, the chipmunk gets 1.
Squirrel 4 gets 1279 nuts during the night, the chipmunk gets 1.
Squirrel 5 gets 1023 nuts during the night, the chipmunk gets 1.
In the morning there are 4091 nuts in the pile, each squirrel gets 818 nuts and the chipmunk gets 1.
Name you program squirrels_yourInitials.iava (yourInitials represents your initials).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started