| | |
Sorting Video titles using a ID numbers
![]() |
Hi eboney.
I know this is a late post, but this can be used for future reference. I'm not going to go in big detail on this, but maybe this will get you started. This code will take user input convert it into an integer. If the input is in the movieid array it will output the user input along with the corresponding movie title. I hope this helps you.
I know this is a late post, but this can be used for future reference. I'm not going to go in big detail on this, but maybe this will get you started. This code will take user input convert it into an integer. If the input is in the movieid array it will output the user input along with the corresponding movie title. I hope this helps you.
Java Syntax (Toggle Plain Text)
public class MovieTitle { public static void main(String []args)throws Exception { // Array examples int [] movieId = {1001, 1002, 1003}; String [] movieTitle = {"title1001", "title1002", "title1003"}; // Declaring variables String inputHolder = new String(); int x, y; // Getting the user Input System.out.print("Enter Movie ID: "); char userInput = (char)System.in.read(); while(userInput >= '0' && userInput <= '9') { inputHolder = inputHolder + userInput; userInput = (char)System.in.read(); } System.in.read(); // Converting chars input to integer int theId = Integer.parseInt(inputHolder); // Executing for loop to match user Input to the correct movie title and ID for(x = 0; x < movieId.length; ++x) { if(theId == movieId[x]) { System.out.println("Id number " + theId + " matches movie title " + movieTitle[x]); } } } }
![]() |
Similar Threads
- Pointers and Sorting Array by Even and Odd numbers (C)
- What is wrong with my sorting function? (C++)
- Another Lottery Program sorting problem (Visual Basic 4 / 5 / 6)
- java sorting problem (Java)
- Sorting huge amount of numbers (C++)
Other Threads in the Java Forum
- Previous Thread: URGENT - Reading from txt file into a 2 dimension array
- Next Thread: required technical guidence for Struts and XML
| Thread Tools | Search this Thread |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card chat class classes client code collision columns component constructor crashcourse database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress integer intellij j2me java javadoc javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop machine map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle plazmic print problem program programming project radio recursion scanner server set sharepoint smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads tree unlimited utility webservices windows






