Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package seachname;
- import java.util.*;
- public class Seachname {
- public static void main(String[] args) throws Exception {
- Scanner search = new Scanner(System.in);
- String[] array = new String[20];
- System.out.println("Please enter 20 names to sort");
- for (int i = 0; i < array.length; i++) {
- array[i] = search.nextLine();
- }
- System.out.print("Enter a search term: ");
- String name = search.next();
- int i;
- boolean found = false;
- for (i = 0; i < array.length; i++) {
- if (array[i] == name) {
- found = true;
- }
- }
- if (found = true){
- System.out.println("Your search term of " + name + " these search results");
- }
- else {
- System.out.println("Your search term of " + name + " did not return any results");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment