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. PLEASE SEE EXAMPLE BELOW FOR STRUCTURE AND HELP 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 java X eimport java.util.Arrays; 2 import java.util.Random; 4 public class Main public static void main(String[1 args) t String testStr" this System.out.println("input: " + testStr); System.out.print Ln(" output: " toCamelCase(testStr)); SENTENCE SHOULD be reTuRned in LOWER CaMeL Case Random rand new Random); int hoManyCaves rand. nextInt (9) 1; int howManyFlashLights- rand.nextInt (3) + 1; int [] caves new int [howManyCaves] int[] flashLights= new int [ho Many FlashL ights]; 10 16 17 for(int i-0; iStep 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