Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions