/**
*
*/
import java.io.*;
import java.util.*;
/**
*
*
*/
public class Linearsearch {
/**
* @param args
*/
public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub
String s[] = new String[5];
boolean found = false;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
for(int i=0;i<5;i++)
{
s[i]=br.readLine();
}
System.out.println("Enter the String to search");
String Search = br.readLine();
for(int k=0;k<5;k++)
{
if (Search.equals(s[k]))
{
System.out.println("String found and it is " +Search);
found = true;
}
}
if(!found){
System.out.println("No search item found");
}
}
}
Output:-
sai
nagendra
bhavani
prasad
battipati
Enter the String to search
battipati
String found and it is battipati
*
*/
import java.io.*;
import java.util.*;
/**
*
*
*/
public class Linearsearch {
/**
* @param args
*/
public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub
String s[] = new String[5];
boolean found = false;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
for(int i=0;i<5;i++)
{
s[i]=br.readLine();
}
System.out.println("Enter the String to search");
String Search = br.readLine();
for(int k=0;k<5;k++)
{
if (Search.equals(s[k]))
{
System.out.println("String found and it is " +Search);
found = true;
}
}
if(!found){
System.out.println("No search item found");
}
}
}
Output:-
sai
nagendra
bhavani
prasad
battipati
Enter the String to search
battipati
String found and it is battipati
No comments:
Post a Comment