Java Sorting and Searching
If anyone could help me with this I would be really thankful!
Write a program that stores the names of these artists in a String array. The program should prompt the user to enter the name of an artist and output that artist's position in the charts or a message saying that they are not present.
You should choose the most appropriate search method introduced in the lecture and modify it so that it handles strings, rather than integers.
View Answers
December 9, 2011 at 12:21 PM
import java.util.*;
class SearchingAndSorting
{
public static void main(String[] args)
{
String names[]={"AAAA","DDDD","FFFF","ZZZZ","KKKKK","PPPP"};
ArrayList<String> list=new ArrayList<String>();
for(int i=0;i<names.length;i++){
list.add(names[i]);
}
Scanner input=new Scanner(System.in);
System.out.print("Enter Name: ");
String name=input.nextLine();
int index;
if(list.contains(name)){
index=list.indexOf(name);
System.out.println("Position: "+(index+1));
}
else{
System.out.println("Artist is not present");
}
}
}
Ads
Related Tutorials/Questions & Answers:
Java Sorting and Searching
Java Sorting and
Searching If anyone could help me with this I would be really thankful!
Write a program that stores the names of these artists in a String array. The program should prompt the user to enter the name
Sorting and Searching
Sorting and Searching Hi i would really be thankful if someone could help me with this
A program is required to ask users to rate the
Java...) {
Scanner input = new Scanner(System.in);
System.out.print("Rate
Java(0-10
Advertisements
Insertion, sorting and searching in array
to perform
searching
and
sorting in array. In the
java code given below we have...;
}
Insertion,
sorting and
searching in array
 ... after
sorting", array);
// Search for element in specified array
Java sorting
Java sorting can somebody help me know how
java sorts? means which... the following links:
Java bubble sort
Java Heap Sort
Java Insertion Sort
Java Merge Sort
Java Selection Sort
Java Quick Sort
hello
Bubble Sorting in Java
Bubble
Sorting in Java Hi,
What is Bubble
Sorting? Guide me where to learn Bubble
Sorting in
Java?
Thanks
Hi,
Check the tutorial at Bubble
Sorting in
Java.
Thanks
Sorting
Sorting can any help me know which
sorting algorithm
java uses for
sorting collection and arrays
Java Sorting
Java Sorting Could somebody help me with this question.
Implement a program to process votes for 5 candidates in a talent contest.
The program should use a String array to hold the names of the 5 candidates and an integer
Java String searching.
Java String
searching. How to search a string in given String array?
import java.util.Scanner;
public class StringSearch {
public... and for
searching
we used userCity.equalsIgnoreCase(city[i
Searching operation in JAva
Searching operation in JAva Sir,
I have made a project for the Dispatch section of my office. I have to search for letters that are dispatched on a particular date. Now there are thousands of letters dispatched on a particular
Searching operation in JAva
Searching operation in JAva Sir,
I have made a project for the Dispatch section of my office. I have to search for letters that are dispatched on a particular date. Now there are thousands of letters dispatched on a particular
Searching operation in JAva
Searching operation in JAva Sir,
I have made a project for the Dispatch section of my office. I have to search for letters that are dispatched on a particular date. Now there are thousands of letters dispatched on a particular
Searching operation in JAva
Searching operation in JAva Sir,
I have made a project for the Dispatch section of my office. I have to search for letters that are dispatched on a particular date. Now there are thousands of letters dispatched on a particular
sorting array in java
sorting array in java How to sort array in
Java or JavaScript?
JavaScript
Sorting array tutorial
Java Sort array of strings
import java.util.*;
class ArrayExample{
public static void main(String
sorting
sorting write a program to arrange
sorting in rows,column and diagonal
java array sorting manual way
java array
sorting manual way Hi,
Anyone has any sample code on how to sort a array manually without using the inbuild
sorting algorithm?
Thanks
sorting
sorting write to a program to arrange the
sorting in rows, column and digonal
sorting
sorting how to do
sorting without using bubble sort,selection sort
searching technique
searching technique Hi,
i need any
searching technique in
java to search the data and give the all possible data by links
searching problem
searching problem how we can make a code in core
java for
searching in hard disk?
i have to make an antivirus as my minor project , so i have need this type code to search the virus in hard disk
searching problem
searching problem how we can make a code in core
java for
searching in hard disk?
i have to make an antivirus as my minor project , so i have need this type code to search the virus in hard disk
searching books
searching books how to write a code for
searching books in a library through jsp
file searching
file searching i need a prog for
searching inside a text file after evry 1 min to find does it hav any new entry
searching string
searching string how to write a program for
searching a string
Hi Friend,
Try this:
import java.util.*;
class SearchString{
public static void main(String[] args){
Scanner input=new Scanner(System.in
searching the data
searching the data respected sir ,
i am making the desktop application ,
so how can i search the data which are stored in the mysql databses through click the button and display in jtable through netbeans dynamically
Sorting an ArrayList
Sorting an ArrayList print("code sample");Hello All,
I am working on a program for school and I am having trouble with
sorting my list... really new at
Java...This is only the second program I am writing for school
linear sorting
linear sorting what is linear
sorting?
can any send me an example
Hi Friend,
Try this:
import java.util.*;
class ArraySort{
public...("After
Sorting: ");
for(int i=0;i<arr.length;i++){
System.out.println