java homework

Budget $10 - $30 USD
Bids 51
Average Bid $22
OPEN Ending in 1 day

Write [url removed, login to view] from page 212 Ninth edition.

" [url removed, login to view] (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)"

Pentagonal numbers illustration and general equation....

Which is Pn = ( 3 * n2 - n )/2

Note for n =1 we have one vertex point

for n = 2 we share vertex points for n=1 and add four more points this gives a pentagonal P2= 5 points

For P3, we share vertex points of P2 and add 7 more points this gives P3 = 12 points

For P4 we add 10 more points + 12 from P3 gives a P4 = 22.

You will read a single integer from standard input and print out the the first n pentagonal numbers, where n was integer just read. All numbers will be printed space then number, last pentagonal number is new line terminated.

Sample Run 1 (Input 2):

Enter an integer: 2

The pentagonal numbers are: 1 5

Sample Run 2 (User input's 4):

Enter an integer: 4

The pentagonal numbers are: 1 5 12 22

Sample Run 3 (NetBeans output window user inputs 7)


Enter an integer: 7

The pentagonal numbers are: 1 5 12 22 35 51 70

BUILD SUCCESSFUL (total time: 7 seconds)

Hint the method getPentagonalNumber( int n ), is singular, but you can write your method to kick out and array 1..n.


For [url removed, login to view] with input 2, you will need to output:space1space5newline, so we print a space then a number.

The only catch the last number ends in newline not space.

Lets look at another example, you want to read in n and print out the squares of 1 up to n^2, last one is newline terminated.

For example, input n=3; Output: "The square numbers are: 1 4 9\n" - this Simple loop will work....

[url removed, login to view]( "The square numbers are: " );

for( int i = 1; i <= n ; ++i ) [url removed, login to view]( i*i + ( i-1<n ? " " : \n" ) );

Get Free Quotes For A Project Like This

Looking to make some money?

  • Set your budget and the time frame
  • Outline your proposal
  • Get paid for your work

Bids on this Project

  • omararodriguezl Profile Picture


    caracas,  Venezuela

    I am a Student of economy in 6 semester. I Have made courses of programing in: -Java -Android - PHP -HTML -HTML5 -CSS I have certificate of Java, android and php in my country.

  • gguliashvili Profile Picture


    Tbilisi,  United States

    I'm working at Cisco systems Inc. I've won various programming competitions. Silver Medal on International olympiad of informatics(IOI). I'm finalist of ACM International Collegiate Programming Olympiad.

  • nishitsharma84 Profile Picture


    Ahmedabad,  India

    I am Nishit Sharma, i have around 6 years of experience in java/j2ee technologies like core java, jsp, servlets, struts, ejb, jpa

  • umiker9 Profile Picture



  • AHarkous Profile Picture


    Nabatieh,  Lebanon

    I learn in lebanese university IT & programming and I'am about to graduate. I like to make designs and play with colors and shapes so I work on photoshop,illustrator and after effects frequently. I have also started recently my journey in 3d world hoping to be professional in modeling and animation as soon as possible.

  • ahsanislam04 Profile Picture


    Lahore,  Pakistan

    I am Software Engeneering also a freelancer i work on projects and assignments related to java,C and C++ with perfection. I also teach programming on skype.

  • airavani2018 Profile Picture


    Baku,  Azerbaijan

    EDUCATION ADA University, Baku, Azerbaijan Bachelor in Computer Science, School of IT & Engineering May 2018 (expected) Selective Coursework: • Discrete Structures • Software Design and Patterns • Principles of Operating Systems Languages: Azerbaijani and Russian – Native English – Fluent Turkish – Intermediate German – Basic MS Office (Word, Excel, Power Point, Outlook), IOS/Android, App Development, Knowledge of Software Design and Patterns, Excellent Problem Solving Skills, Computer skills: July 1 - July 28, 2015 Object-Oriented Analysis and Design, Arduino, Keynote, Numbers, Pages, NetBeans, Eclipse, WireShark Programming Languages: Java, Swift, C++, C#, C, JavaScript, Pascal

  • masroor636 Profile Picture


    Karachi,  Pakistan

    Masroor is a Computer Science graduate from Sindh Madressatul Islam, University and he completed an internship with one of the most prestigious groups of Newspaper for three months during completion of bachelor's degree. He has a good hand in software development. His passion is inventing new and more powerful logics for the development of software. He is able to work independently or as part of a team in a busy environment. He has good communication as well as problem-solving. Masroor is awarded a Certificate of Completion of exchange program by Hainan Tropical Ocean University, Sanya, Hainan province, China. Specialties: Java SE, Java EE, Servlets, MySql, EJB, HTML, CSS, JavaScript, Jquery.

  • SooryaRaghu Profile Picture


    Singapore,  Singapore

  • luffymurom Profile Picture


    Ha noi,  Vietnam

    Hi, everyone. I am Dinh. I am senior in c, java and python. Hope to work with you. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<