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 Java program with an object class called Pentagon and a test class called testPentagon. The Pentagon object class must contain a method with the following header that calculates and return a pentagonal number: public int calcPentagonalNumber(int n) Use the formula: n(3n-1)/2 In the test class: Make use of the calcPentagonalNumber(n) method in the Pentagon object class and display the first 100 pentagonal numbers with 10 numbers on each line.
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 Java program with an object class called Pentagon and a test class called testPentagon.
The Pentagon object class must contain a method with the following header that calculates and return a pentagonal number:
public int calcPentagonalNumber(int n)
Use the formula: n(3n-1)/2
In the test class:
Make use of the calcPentagonalNumber(n) method in the Pentagon object class and display the first 100 pentagonal numbers with 10 numbers on each line.
NOTE: NO marks if the pentagonal number is calculated in the test class. Your solution must be an object-oriented solution
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images