Skip to content

Instantly share code, notes, and snippets.

@imryan
Last active December 25, 2015 19:29
Show Gist options
  • Select an option

  • Save imryan/7028394 to your computer and use it in GitHub Desktop.

Select an option

Save imryan/7028394 to your computer and use it in GitHub Desktop.
Calculates the sum of cubes.
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