1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lyudmila [28]
3 years ago
10

6-1) (Math: pentagonal numbers) A pentagonal number is defined as n(3n–1)/2 for n = 1, 2, . . ., and so on. Therefore, the first

few numbers are 1, 5, 12, 22, . . . . Write a method with the following header that returns a pentagonal number: public static int getPentagonalNumber(int n) Write a test program that uses this method to display the first n pentagonal numbers with 10 numbers on each line, one space between each number, and the user entering the integer value for n.
Computers and Technology
1 answer:
Igoryamba3 years ago
7 0

Answer:

Check the explanation

Explanation:

public class Exercise_06_01 {

/** Main Method */

public static void main(String[] args) {

 final int NUMBER_OF_PENTAGONALS = 100; // Display the first 100 pentagonals

 final int NUMBER_PER_LINE = 10; // Display 10 number per line

 // Display the first 100 pentagol numbers

 System.out.println("The first 100 pentagonal numbers, ten per line: ");

 for (int i = 1; i <= NUMBER_OF_PENTAGONALS; i++) {

  // Print ten numbers per line

  if (i % NUMBER_PER_LINE == 0)  

   System.out.printf("%7d\n", getPentagonalNumber(i));

  else

   System.out.printf("%7d", getPentagonalNumber(i));

 }

}

/** Return a pentagonal number */

public static int getPentagonalNumber(int n) {

 return (n * (3 * n - 1)) / 2;

}

}

You might be interested in
WILL CHOOSE BRAINLIEST! in cells D6 through D8, enter formulas to calculate the values of the stocks. The formulas should multip
gtnhenbr [62]

Answer:

Alice Grant has been saving and investing part of her salary for several years. She decides to keep track of her investments on a worksheet. The file Application 9-7 contains the investments of Alice Grant. She owns several types of investments:

Explanation:

8 0
2 years ago
To calculate perimeter of a rectangle​
quester [9]

a+b+c+d= perimeter of a rectangle

5 0
3 years ago
Read 2 more answers
Any BTS army here
kirill115 [55]
I am bts army unite

5 0
3 years ago
Read 2 more answers
What are the differences between sequential and random files? Which one do you think is better and why?
sukhopar [10]

Answer:

Sequential is better

Explanation:

Sequential is more organized while the more easier to make but less dependable one is random.

sequential is used for things such as date of birth, or where someone was born.

you can't do that with a random file.

5 0
4 years ago
Create a simple program of your own using a Loop that counts and displays numbers 1-10.
avanturin [10]

Answer:

I think

Explanation:

you....

8 0
3 years ago
Other questions:
  • What is the answer to that question
    13·2 answers
  • In Word, tables can be styled much like text can.<br> True<br> False
    6·1 answer
  • When creating an electronic slide presentation, Eliza should ensure that her presentation contains
    6·1 answer
  • In the FEMA case study, the BureauNet software was the primary reason behind the increased speed and relevance of the reports FE
    15·2 answers
  • Think back over the information presented in the lesson about how you can skillfully use the Internet when doing research. Selec
    14·1 answer
  • What is Administrator windows 10
    8·1 answer
  • what are the products of light-dependent reactions? Why are they important in lighy independent reactions?​
    6·2 answers
  • What is the possible output from system.out.println((int)math.random() * 4)?
    8·1 answer
  • What do you think color theory<br> in web design is?
    14·1 answer
  • It is most commonly used for self-running presentations.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!