Question

Write a programming java that prints the sum of cubes. Prompt for and read two integer...

Write a programming java that prints the sum of cubes. Prompt for and read two integer values from the user and print the sum

of each value raised to the third power, i.e., (?3+?3). Sample output:

(user input)

Enter x as an int:

3

Enter y as an int:

4

(3^3) + (4^3) = 91

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Copy the below code in SumOfCubes.java file

******SumOfCubes.java*****

import java.util.Scanner;//importing scanner class
public class SumOfCubes // defiining class

{
public static void main(String args[]){
   

int x,y,sum; // taking integer type variables

Scanner sc = new Scanner(System.in); //making scanner object

System.out.println("Enter x as an int:"); // printing

x = sc.nextInt(); // string in x

System.out.println("Enter y as an int:"); // printing

y = sc.nextInt(); // storing in y

sum= (x*x*x)+(y*y*y); // calculating sum

System.out.println("("+x+"^3) + ("+y+"^3) = "+sum); // displaying sum with equation

}
}

Screenshot for orientation:

Two Output examples:

Extra Note-

Every thing after "// " is a comment , it is ignored by the compiler

Give special attention to spellings. And letter case

+ Is used for concatenation of strings

Any thing else let me know in the comment

Thank if this answer helps you please up vote thnk you !

Add a comment
Know the answer?
Add Answer to:
Write a programming java that prints the sum of cubes. Prompt for and read two integer...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT