0

# [HOW TO CODE]A java program that Sums the cube of three numbers, and then determining the sum whether it is Positive or Negative

In this problem...there are two problems that needs to be executed; 1.) Sum of the cubes of the three inputted integer. and; 2.) Determining the sum whether it is positive or negative. I tried coding these two..but still I couldn’t do it right. How do I do it??

12 ответов

+ 4

ruiririririri ,
you are talking of "cubes of the three inputted integer". this means for the numbers: 2, 3, 4: (2 ^ 3) + (3 ^ 3) + (4 ^ 3), which is:
(2 * 2 * 2) + (3 * 3 * 3) + (4 * 4 * 4) or: (8) + (27) + (64) => 99.
please correct me if i am wrong
but the code you presented something else, as Math.cbrt(...) is used to return the cube root which is something different.

+ 1

Link to the code?
https://www.sololearn.com/post/75089/?ref=app

+ 1

Hi! Ipang I hope this helps...
Link for the code in Determining whether an integer is positive or negative
https://code.sololearn.com/c0Vel0N2X1v6/?ref=app
Here is the link of the code of the Sum of the three cubed integer
https://code.sololearn.com/c9wRq9Mw1z5G/?ref=app
(This code is wrong..still needs to be edited)
I tried merging the two...but I don’t know how to do it...

+ 1

Ipang yes it is Aleksei’s code...I am not claiming its mine

+ 1

Okay, that one works just fine ...
You will need to put each code to a separate method, in your class.
Create one method for calculating cube roots, and create another one for checking positive/negative number. Copy/paste the code from main() method into those new methods.
I think you can do this ...

+ 1

Ipang I’ll try to apply your advice...Thank you!

+ 1

Ipang Thank you!

+ 1

Lothar I’ll try to apply your advice. Thank you! Have a nice day.

0

The problem with cube root addition program lies at line 9 and 14. The quotes used for the string is not regular double quote.

0

The positive/negative code is Aleksei's code ...

0

I'll be here standing by ...

0

Nicee wow