Computer Science, asked by muskanagrawal61781, 8 months ago

Write a javwritea program to input ten numbers. use a function to find and print the square and cube of each number. allow the user to input the number using scanner class.

Answers

Answered by prashantrohilla32
2

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

    Scanner sc=new Scanner(System.in);

    int []a=new int[10];

    int square;

    int cube;

   

    for(int i=0;i<a.length;i++)

    {

        a[i]=sc.nextInt();

    }

   

    for(int j=0;j<a.length;j++)

    {   int b=a[j];

        square=b*b;

        cube= b*b*b;

        System.out.println("Element= "+a[j]+" Square= "+square+" and Cube= "+cube);

    }

   

}

}

Attachments:
Similar questions