Question
Youre on a treasure hunt through a series of caves deep in the jungle. You are equipped with a certain number of flashlights, capable of
Youre on a treasure hunt through a series of caves deep in the jungle. You are equipped with a certain number of flashlights, capable of finding specific treasures depending on the flashlights integer value.
How this works:
1.Create a random series of caves (integer array). There must be between 1 and 10 caves.
2.Fill each cave with a treasure (an integer between 1 and 9).
3.Randomly decide how many flashlights to take(integer array). You will take between 1 and 4 flashlights.
4.Randomly choose which flashlights to take. Flashlights will be represented by an integer value between 1 and 1,000,000.
Can this flashlight find that treasure?:
A caves treasure, represented by an integer value between 1 and 9 can only be discovered by a flashlight whose values recursive sum of its digits make up the caves value.
Example:
Flashlight value = 1174 so 1+1+7+4 = 13 and 1+3 = 4.
Therefore, any cave with a value of 4 can have its treasure found by this flashlight
Create two methods, treasureHunt and searchCave. These methods will work together, treasureHunt will call searchCave. treasureHunt will be written iteratively and searchCave will be written recursively.Please note example below for formatting and further clues/help:
Main method link;
https://ibb.co/DpHp6nF
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