subject

Write a recursive method public static int teddy(int initial, int goal, int increment) that simulates a variant of the “teddy bears” game between the player (you) and your friend, and returns the minimum number of steps you would need to end up with goal bears. you start with an initial number of stuffed bears. during each step of the game you may perform one of the following actions: (a) ask for and receive increment more bears from your friend; (b) give away increment of your bears to your friend; (c) if you have an even number of bears, you can give exactly half your bears to your friend; or (d) if you have an even number of bears, you can take an additional number of bears equal to half your current number of bears. if you fail to obtain the goal within 10 steps, the method returns -1. you may write methods if you like.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 23:00
Which type of tab stop is most for weights and measurements?
Answers: 1
question
Computers and Technology, 24.06.2019 08:10
Where are american poets found in the dewey decimal system
Answers: 1
question
Computers and Technology, 24.06.2019 16:00
How are roger williams, james oglethorpe, and william penn similar?
Answers: 3
question
Computers and Technology, 24.06.2019 17:30
What is the next step if your volume does not work on computer
Answers: 2
You know the right answer?
Write a recursive method public static int teddy(int initial, int goal, int increment) that simulate...
Questions
question
Biology, 11.12.2021 16:10
question
Mathematics, 11.12.2021 16:10
question
Arts, 11.12.2021 16:10
question
Spanish, 11.12.2021 16:10
question
World Languages, 11.12.2021 16:10
question
Mathematics, 11.12.2021 16:10
question
English, 11.12.2021 16:10
question
Biology, 11.12.2021 16:20
Questions on the website: 13722360