@@ -0,0 +1,1337 @@
+import java.util.Scanner;%0A%0Apublic class find_largest_or_smallest %7B%0A%09public static void main(String%5B%5D args) %7B%0A%09%09//directions and gather user input%0A%09%09Scanner s = new Scanner(System.in);%0A%0A%09%09System.out.println(%22How many numbers are in your list?%22);%0A%09%09int length = s.nextInt();%0A%09%09%0A%09%09int%5B%5D list = new int%5Blength%5D;%0A%09%09System.out.println(%22Enter your list%22);%0A%09%09for(int i = 0; i %3C length; i++) %7B%0A%09%09%09list%5Bi%5D = s.nextInt();%0A%09%09%7D%09%09%0A%09%09s.nextLine();%0A%0A%09%09System.out.println(%22Would you like to find the smallest or largest number?%22);%0A%09%09String target = s.nextLine();%0A%0A%09%09s.close();%0A%0A%09%09//calculate and print result%0A%09%09switch(target) %7B%0A%09%09%09case %22smallest%22: %0A%09%09%09%09int smallest = smallest(list);%0A%09%09%09%09System.out.println(%22The smallest number in the list is: %22 + smallest);%0A%09%09%09%09break;%0A%09%09%09case %22largest%22:%0A%09%09%09%09int largest = largest(list);%0A%09%09%09%09System.out.println(%22The largest number in the list is: %22 + largest);%0A%09%09%09%09break;%09%0A%09%09%09default:%0A%09%09%09%09System.out.println(%22Invalid selection%22);%0A%09%09%7D%0A%09%7D%0A%0A%09public static int smallest(int%5B%5D list) %7B%0A%09%09int smallest = list%5B0%5D;%0A%09%09for(int i = 0; i %3C list.length; i++) %7B%0A%09%09%09if(smallest %3E list%5Bi%5D) %7B%0A%09%09%09%09smallest = list%5Bi%5D;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return smallest;%0A%09%7D%0A%09%0A%09public static int largest(int%5B%5D list) %7B%0A%09%09int largest = list%5B0%5D;%0A%09%09for(int i = 0; i %3C list.length; i++) %7B%0A%09%09%09if(largest %3C list%5Bi%5D)%7B%0A%09%09%09%09largest = list%5Bi%5D;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return largest;%0A%09%7D%0A%7D%0A

finds either largest or smallest number in given list