Question: 1. Create a program named bunnies.java that recursively calculates the total number of rabbit ears. Rabbits are in a line numbered 1, 2, 3, 4,

 1. Create a program named bunnies.java that recursively calculates the total

1. Create a program named bunnies.java that recursively calculates the total number of rabbit ears. Rabbits are in a line numbered 1, 2, 3, 4, ... The even numbered rabbits have 2 ears. The odd numbered rabbits have 3 ears. The exception to both of these rules is that every 5th rabbit has only 1 ear. Create a recursive method (no for or while loops) to calculate the total number of ears named BunnyEars(n). The recursive method should calculate the number of ears on the current rabbit, and call itself with the number of ears on the previous rabbit. BunnyEars(1) = 3 BunnyEars(6) = 13 BunnyEars(2) = 5 BunnyEars(7) = 16 BunnyEars(3) = 8 BunnyEars(4) = 10 BunnyEars(8) = 18 BunnyEars(9) = 21 BunnyEars(5) = 11 BunnyEars(10) = 22 1 2 3 4 5 6 7 8 9 10 A1 IVI A1 \/1 IVI VA || | || TIIT || || || III III || | || || | || VIII/ 1117 VIII/ \/\/ VII/ 1117 / oo / oo 7 oo / oo / oo 7 00 / 00 / 00 / oo / oo = L_Y_/= = __ Y_/= = \_Y_/= = \_Y_/= = \_Y_/= = _ Y_/= = \_ Y_/= = \_Y_J = = \_Y_/= = \_Y_/= Example output How many bunnies are in the line? 5 This is a total of 11 ears

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!