Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In a bowling game, there are a total of ten pins arranged in four rows, like thi

ID: 3669045 • Letter: I

Question

In a bowling game, there are a total of ten pins arranged in four rows, like this:

   *

* *

* * *

* * * *

Note that there's one pin in the first row, two in the second and so on.

Now, suppose that there's a strange alien civilization where they bowl using 8,359 rows of pins. Furthermore, their pins are arranged with one pin in the first row, three in the second and so on.

*

   * * *

* * * * *

Write a java program that uses a while loop to compute and display how many total pins there would be in such a game. (All i need is the number of pins, you dont have to display the pin arrangement

Explanation / Answer

import java.util.*;

import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
   public static void main (String[] args) throws java.lang.Exception
   {
       int row = 1;
       int total = 0;

       while(row<=8359) {
           total = total + (2*row -1);
          row = row+1;

}
       System.out.println("Total number of pins = "+total);
      
   }
}

//answer = 69872881