Question: Homework: Write a sample program in Java to compute the number of chocolate spheres stacked in a triangular pyramid within x triangular layers. n(x) is

Homework:

Write a sample program in Java to compute the number of chocolate spheres stacked in a triangular pyramid within x triangular layers. n(x) is the number of balls required to make x layers.

The value of x is entered by users.

(Try for x = 4, x =5.)

//Formula//

n(x) = 1/6 * x^3 + 1/2 * x^2 + 1/3 x

*Use Buffered Reader class and method readline();

*No if, no loops. Use Java, and be basic so I can understand your coding.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!