write a program to accept set of 8 integers and print array elements along with the index number of each elements and square of each element in three columns
Answers
Answered by
0
Answer:
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Integer [] numbers=new Integer[8];
System.out.println("Enter number:");
for (int i=0;i<8 ;i++ )
{
numbers[i]=in.nextInt();
}
System.out.println("Index|Value|Square");
for (int i=0;i<8 ;i++ )
{
System.out.println(i+"\t"+numbers[i]+"\t"+numbers[i]*numbers[i]);
}
}
}
Explanation:
Similar questions
Computer Science,
5 months ago
Computer Science,
5 months ago
Math,
5 months ago
English,
10 months ago
Chemistry,
10 months ago
Math,
1 year ago
Biology,
1 year ago