write a program in java to input 10 numbers. Use a function to find and print the cube of each number
Answers
Answered by
8
imort java.util.*;
class CubeOfNumbers{
public static void findCube(int num[]){
for(int i=0;i<num.length;i++){
System.out.println("Cube of "+num[i]+" is: "+(num[i]*num[i]*num[i]));
}
}
public static void main(String args[]){
Scanner input=new Scanner(System.in);
int array[]=new int[10];
for(int i=0;i<array.length;i++){
array[i]=input.nextInt();
}
findCube(array);
}
}
class CubeOfNumbers{
public static void findCube(int num[]){
for(int i=0;i<num.length;i++){
System.out.println("Cube of "+num[i]+" is: "+(num[i]*num[i]*num[i]));
}
}
public static void main(String args[]){
Scanner input=new Scanner(System.in);
int array[]=new int[10];
for(int i=0;i<array.length;i++){
array[i]=input.nextInt();
}
findCube(array);
}
}
Similar questions
Political Science,
8 months ago
Geography,
8 months ago
Chemistry,
8 months ago
Math,
1 year ago
Social Sciences,
1 year ago
History,
1 year ago