33. WAP in Java to assign 10 different numbers in a Single Dimensional Array and display the
maximum and the minimum number of the array elements.
Answers
Explanation:
import java.util.Scanner;
public class KboatSDASearch
{
public void search(int m[], int ns) {
boolean found = false;
for (int i = 0; i < m.length; i++) {
if (m[i] == ns) {
found = true;
break;
}
}
if (found)
System.out.println("Number is present");
else
System.out.println("Number is not present");
}
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int arr[] = new int[10];
System.out.println("Enter 10 numbers");
for (int i = 0; i < arr.length; i++) {
arr[i] = in.nextInt();
}
System.out.print("Enter number to search: ");
int num = in.nextInt();
KboatSDASearch obj = new KboatSDASearch();
obj.search(arr, num);
}
}