Last active
December 25, 2015 19:29
-
-
Save imryan/7028394 to your computer and use it in GitHub Desktop.
Calculates the sum of cubes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Scanner; | |
| public class Cubes | |
| { | |
| public static void main(String[] args) | |
| { | |
| // Declare variables | |
| Scanner sc = new Scanner(System.in); | |
| int cube1, cube2; | |
| double sum; | |
| // Get input | |
| cube1 = sc.nextInt(); | |
| cube2 = sc.nextInt(); | |
| // Calculate sum | |
| sum = (Math.pow(cube1, 3) + Math.pow(cube2, 3)); | |
| // Output result | |
| System.out.println("Sum is: " + sum); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment