math pentagonal numbers java

Ace your studies with our custom writing services! We've got your back for top grades and timely submissions, so you can say goodbye to the stress. Trust us to get you there!


Order a Similar Paper Order a Different Paper


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.


SAMPLE RUN #1

— Prompts For Keyboard/Console/Standard Input —

Enter an integer  for the n pentagonal numbers you want displayed:


Inputs

— Keyboard/Console/Standard Input stdin —

20 


Outputs 

— Monitor/Console/Standard Output  —

Enter an integer  for the n pentagonal numbers you want displayed:1 5 12 22 35 51 70 92 117 145 
176 210 247 287 330 376 425 477 532 590 


What The Console Looks Like In An Interactive Session:

(Note: this combines standard input with standard output )

>java PentagonalNumbers 
Enter an integer  for the n pentagonal numbers you want displayed: 20 
1 5 12 22 35 51 70 92 117 145 
176 210 247 287 330 376 425 477 532 590 


SAMPLE RUN #2

— Prompts For Keyboard/Console/Standard Input —

Enter an integer  for the n pentagonal numbers you want displayed:


Inputs

— Keyboard/Console/Standard Input stdin —

33 


Outputs 

— Monitor/Console/Standard Output  —

Enter an integer  for the n pentagonal numbers you want displayed:1 5 12 22 35 51 70 92 117 145 
176 210 247 287 330 376 425 477 532 590 
651 715 782 852 925 1001 1080 1162 1247 1335 
1426 1520 1617 


What The Console Looks Like In An Interactive Session:

(Note: this combines standard input with standard output )

>java PentagonalNumbers 
Enter an integer  for the n pentagonal numbers you want displayed: 33 
1 5 12 22 35 51 70 92 117 145 
176 210 247 287 330 376 425 477 532 590 
651 715 782 852 925 1001 1080 1162 1247 1335 
1426 1520 1617 


SAMPLE RUN #3

— Prompts For Keyboard/Console/Standard Input —

Enter an 
integer  for the n pentagonal numbers you want displayed:


Inputs

— Keyboard/Console/Standard Input stdin —

67 


Outputs 

— Monitor/Console/Standard Output  —

Enter an 
integer  for the n pentagonal numbers you want displayed:1 5 12 22 35 51 70 92 117 145 

176 210 247 287 330 376 425 477 532 590 

651 715 782 852 925 1001 1080 1162 1247 1335 

1426 1520 1617 1717 1820 1926 2035 2147 2262 2380 

2501 2625 2752 2882 3015 3151 3290 3432 3577 3725 

3876 4030 4187 4347 4510 4676 4845 5017 5192 5370 

5551 5735 5922 6112 6305 6501 6700 


What The Console Looks Like In An Interactive Session:

(Note: this combines standard input with standard output )

>java PentagonalNumbers 

Enter an 
integer  for the n pentagonal numbers you want displayed:
 67 

1 5 12 22 35 51 70 92 117 145 

176 210 247 287 330 376 425 477 532 590 

651 715 782 852 925 1001 1080 1162 1247 1335 

1426 1520 1617 1717 1820 1926 2035 2147 2262 2380 

2501 2625 2752 2882 3015 3151 3290 3432 3577 3725 

3876 4030 4187 4347 4510 4676 4845 5017 5192 5370 

5551 5735 5922 6112 6305 6501 6700 


SAMPLE RUN #4

— Prompts For Keyboard/Console/Standard Input —

Enter an 
integer  for the n pentagonal numbers you want displayed:


Inputs

— Keyboard/Console/Standard Input stdin —

43 


Outputs 

— Monitor/Console/Standard Output  —

Enter an 
integer  for the n pentagonal numbers you want displayed:1 5 12 22 35 51 70 92 117 145 

176 210 247 287 330 376 425 477 532 590 

651 715 782 852 925 1001 1080 1162 1247 1335 

1426 1520 1617 1717 1820 1926 2035 2147 2262 2380 

2501 2625 2752 


What The Console Looks Like In An Interactive Session:

(Note: this combines standard input with standard output )

>java PentagonalNumbers 

Enter an 
integer  for the n pentagonal numbers you want displayed:
 43 

1 5 12 22 35 51 70 92 117 145 

176 210 247 287 330 376 425 477 532 590 

651 715 782 852 925 1001 1080 1162 1247 1335 

1426 1520 1617 1717 1820 1926 2035 2147 2262 2380 

2501 2625 2752 

compile w NetBeans

Writerbay.net

Looking for top-notch essay writing services? We've got you covered! Connect with our writing experts today. Placing your order is easy, taking less than 5 minutes. Click below to get started.


Order a Similar Paper Order a Different Paper