Question: Must be done in java Consider a frame of bowling pins shown below, where each * represents a pin: * * * * * *
Must be done in java
Consider a frame of bowling pins shown below, where each * represents a pin:
*
* *
* * *
* * * *
* * * * *
There are 5 rows and a total of 15 pins.
If we had only the top 4 rows, then there would be a total of 10 pins.
If we had only the top three rows, then there would be a total of six pins.
If we had only the top two rows, then there would be a total of three pins.
If we had only the top row, then there would be a total of one pin.
Write a program that takes as input the number of rows n and outputs the total number of pins that would exist in a pyramid with n rows.
NOTE: Your implementation must include the definition/implementation and use/calling of a recursive method numberOfPins that is passed the number of rows to its parameter variable, and returns the number of pins.
-
Use the Design Recipe to design the algorithm for each method (main and others), showing all work as comments in the source code (.java) file.
Using Eclipse, implement the algorithm as a program.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
