[ Write a Program to input 10 numbers into an integer array and check whether all numbers are 3 digit number or not.
Program Code :
import java.util.*;
class Three_Digit_No
{
public static void main(String args[])
{
int i,f=0;
int n[]=new int[10];
Scanner sc=new Scanner(System.in);
//Accepting 10 Array Element
for (i=0;i<10;i++)
{
System.out.print("Enter the Array Element = ");
n[i]=sc.nextInt();
}
for (i=0;i<10;i++)
{
//Checking All Array Element are 3 Digit No. or Not
if(n[i]<100 || n[i]>999)
f=1;
}
if(f==0)
System.out.println("In this Array all are 3 Digit No");
else
System.out.println("In this Array all are Not 3 Digit No");
}
}
No comments