Write a Java program to display the cube of the number upto given an integer


Introduction

In this demo I have used NetBeans IDE 8.2 for debugging purpose. But you can use any java programming language compiler as per your availability..


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. import java.util.Scanner;
  2. public class JavaExcercise {
  3.  
  4. public static void main(String[] args)
  5.  
  6. {
  7. int i,n;
  8.  
  9. System.out.print("Enter number of terms : ");
  10. Scanner num = new Scanner(System.in);
  11. n = num.nextInt();
  12.  
  13. for(i=1;i<=n;i++)
  14. {
  15. System.out.println( "cube of " +i+" is : "+(i*i*i));
  16. }
  17. }
  18. }

Result

java techstudy.org

     





Related Topics




Popular Posts