Created
October 21, 2013 17:34
-
-
Save joeyv/7087765 to your computer and use it in GitHub Desktop.
Cubes two inputs and adds them
This file contains 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 | |
double cube1, cube2; | |
double sum; | |
Scanner sc = new Scanner(System.in); | |
// Get input | |
cube1 = sc.nextInt(); | |
cube2 = sc.nextInt(); | |
// Calculate cubes and sum | |
cube1 = (Math.pow(cube1, 3)); | |
cube2 = (Math.pow(cube2, 3)); | |
sum = cube1 + cube2; | |
// Output result | |
System.out.println("Cube 1: " + cube1 + "\nCube 2: " + cube2 + "\nSum is: " + sum); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment