program to Find cube Of Number In Java

You are here : Home / Core Java Tutorials /

In this core java programming tutorial we will write a program to Find cube Of Number In Java.






Program/SourceCode / Example to Find cube Of Number In Java>
import java.util.Scanner;
/*
* Write a program to Find cube Of Number In Java
*/
public class CubeOfNumberInJava {
   public static void main(String[] args) {
  
          Scanner scanner = new Scanner(System.in);
          System.out.print("Enter number : ");
          int number = scanner.nextInt();
          //calculate cube of number
          int cubeOfNumber = number * number * number;
         
          System.out.println("cube of "+number+" is "+cubeOfNumber);
         
   }
}
/*OUTPUT
Enter number : 3
cube of 3 is 27
*/



So, in this core java programming tutorial we wrote a program to Find cube Of Number In Java.


Having any doubt? or you you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.



RELATED LINKS>








Level2 programs
























Must read for you :
Labels:

No comments:

Post a Comment