Friday, July 15, 2011

Problem 6

public static void main(String[] args) {
// TODO code application logic here
Scanner stdIN= new Scanner(System.in);
String songs=
"1. Green Day- American Idiot\n"+
"2. Jesus Jones- Right Here\n"+
"3. Indigo Girls- Closer to Fine\n"+
"4. Peter Tosh - Equal Rights\n";
String searchText;
int foundIndex;
int count=0;
System.out.print("Enter Search text; ");
searchText=stdIN.nextLine();
if(songs.contains(searchText))
{
count++;
}
else
{
System.exit(0);
}
System.out.println("Number of ourrances of \"" +
searchText + "\" :"+count);
}
}

No comments:

Post a Comment