import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int [] Numbers={-10,0,90,70,40,50,20,30,80,60,100};
System.out.print("Enter an integer number that u want to search between 0 to 100");
int searchItem=input.nextInt();
int position =0;
boolean found=false;
while(position<Numbers.length&& !found){
if (Numbers[position]== searchItem){
found=true;
System.out.println("The number is in Numbers[] array index" + position+ ".");
}else{
position=position + 1;
}
}
}
}
class Main {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int [] Numbers={-10,0,90,70,40,50,20,30,80,60,100};
System.out.print("Enter an integer number that u want to search between 0 to 100");
int searchItem=input.nextInt();
int position =0;
boolean found=false;
while(position<Numbers.length&& !found){
if (Numbers[position]== searchItem){
found=true;
System.out.println("The number is in Numbers[] array index" + position+ ".");
}else{
position=position + 1;
}
}
}
}
Комментариев нет:
Отправить комментарий