[HOW TO CODE]A java program that Sums the cube of three numbers, and then determining the sum whether it is Positive or Negative | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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??

6th Oct 2021, 10:05 AM
ruiririririri
ruiririririri - avatar
12 Answers
+ 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.
6th Oct 2021, 11:01 AM
Lothar
Lothar - avatar
6th Oct 2021, 10:06 AM
Ipang
+ 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...
6th Oct 2021, 10:26 AM
ruiririririri
ruiririririri - avatar
+ 1
Ipang yes it is Aleksei’s code...I am not claiming its mine
6th Oct 2021, 10:48 AM
ruiririririri
ruiririririri - avatar
+ 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 ...
6th Oct 2021, 10:53 AM
Ipang
+ 1
Ipang I’ll try to apply your advice...Thank you!
6th Oct 2021, 10:53 AM
ruiririririri
ruiririririri - avatar
+ 1
Ipang Thank you!
6th Oct 2021, 10:55 AM
ruiririririri
ruiririririri - avatar
+ 1
Lothar I’ll try to apply your advice. Thank you! Have a nice day.
6th Oct 2021, 11:10 AM
ruiririririri
ruiririririri - avatar
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.
6th Oct 2021, 10:42 AM
Ipang
0
The positive/negative code is Aleksei's code ...
6th Oct 2021, 10:44 AM
Ipang
0
I'll be here standing by ...
6th Oct 2021, 10:54 AM
Ipang
0
Nicee wow
6th Oct 2021, 11:40 AM
Arthur Zzekron 10