(Math: pentagonal numbers) java

Oct 19th, 2014
FratBro23
Category:
Programming
Price: $55 USD

Question description


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

Tutor Answer

(Top Tutor) Daniel C.
(997)
School: UT Austin
PREMIUM TUTOR

Studypool has helped 1,244,100 students

8 Reviews


Summary
Quality
Communication
On Time
Value
ddg82
Dec 4th, 2016
" Thanks, good work "
kenmwao2
Nov 22nd, 2016
" Solid work, thanks. "
tinytim47
Nov 20th, 2016
" Wow this is really good.... didn't expect it. Sweet!!!! "
jestin7
Nov 11th, 2016
" This tutor is great! "
lilmoe415
Oct 29th, 2016
" Thank you, Thank you, for top quality work, this is your guy!! "
dontuwannaknow
Oct 6th, 2016
" Excellent work as always thanks so much "
thargrow
Sep 27th, 2016
" Very Satisfied. "
SjSurvivor143
Sep 23rd, 2016
" Thanks for the help. "
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1821 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors