+ 2
/*I m just a beginner so did my own long way*/ /*lets hope for someone to make it shorter */ import java.util.Scanner; class Sololearn{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int[] arr=new int[10]; int i=0; /*taking array elements as an input*/ System.out.println("Enter the 10 digits:"); while(sc.hasNextInt()){ arr[i]=sc.nextInt(); i++; if(i==10){ break;} } System.out.println("********Squares********"); for(i=0;i<arr.length;i++) { System.out.println("Squares of"+" "+arr[i]+" is "+arr[i]*arr[i]); } System.out.println("********Cubes********"); for(i=0;i<arr.length;i++) { System.out.println(" cubes of"+" "+arr[i]+" is "+arr[i]*arr[i]*arr[i]); } } }
31st Oct 2017, 11:36 AM
Aman Shah
Aman Shah - avatar