good day sir's/ma'am ,

please help on how to search an inputted elements to an array...
for example...

i added a name "JOSEPH" and Address "ILOCOS"

and i got an option search in my code and i don't know how i will gonna it... please help me..

import java.util.Scanner;
import java.io.*;

class CaseStudy
{
	public static void main(String[]args)
	{
		
	Scanner in = new Scanner(System.in);

	String[] name = new String[1024];
	String[] address = new String[1024];
	int x = 0;
	char option;
	String exit = " Thank you for using my program ";
	String menu = "Case Study in CS ELECTIVE 1";
	boolean found = false;
	
	System.out.printf("\t%s",menu);
	System.out.println();
			
		do{		
			System.out.println("\n[A]Add");
			System.out.println("[R]Report ");
			System.out.println("[S]earch ");
			System.out.println("[Q]uit ");
			System.out.print("Enter your choice : ");
			option = in.next().charAt(0);



			
			switch(option)
			{
			case 'A':
			case 'a':	
				System.out.print("\n\n\nEnter Name: ");
				name[x] = in.next();
				System.out.print ("Enter Address : ");
				address[x] = in.next();
  				x++;
				break;

			case 'R':
			case 'r':	
				for (int j = 0 ; j < x ;j++)
				{
				System.out.println(name[j]);
				System.out.println(address[j]);	
				}
				break;
                        
			case 's':
			case 'S':
			
			System.out.print("Enter a name to search: ");
			String search = in.next();
				
				for(int j =0; j< x; j++) 
				{
					if(search == name[j])
					{
					System.out.println(name[j]);
					System.out.println(address[j]);
					found = true;
					break;
					}

					if(!found)
					{
					System.out.print("NAME NOT FOUND!!!");
					}
				}
			break; 
			      
			case 'Q':
			case 'q':
                                System.out.println("Thank you for using our Program");
                                break;
                                default:
                                System.out.println("Wrong input");
                                break;
			}
			

		}while(option != 'q');
	}


}

please help me on what code will i put in my case 'S' 's'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.