944,209 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 2752
  • Java RSS
Sep 20th, 2004
0

Sorting Video titles using a ID numbers

Expand Post »
Hello everyone,


I am trying to write a program that will list all my videos by title and also by ID# and sort titles. Also I want the user to enter a ID# and they would see what title is associated with the id #.

Can anyone give me a sample on how I write such a program

Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
eboney is offline Offline
1 posts
since Sep 2004
Sep 21st, 2004
0

Re: Sorting Video titles using a ID numbers

You could use a database and sql to query all that you want.
Team Colleague
Reputation Points: 45
Solved Threads: 56
Unauthenticated Liar
nanosani is offline Offline
1,767 posts
since Jul 2004
Oct 4th, 2004
0

Re: 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.

Java Syntax (Toggle Plain Text)
  1. public class MovieTitle
  2. {
  3. public static void main(String []args)throws Exception
  4. {
  5.  
  6. // Array examples
  7. int [] movieId = {1001, 1002, 1003};
  8. String [] movieTitle = {"title1001", "title1002", "title1003"};
  9.  
  10. // Declaring variables
  11. String inputHolder = new String();
  12. int x, y;
  13.  
  14. // Getting the user Input
  15. System.out.print("Enter Movie ID: ");
  16. char userInput = (char)System.in.read();
  17. while(userInput >= '0' && userInput <= '9')
  18. {
  19. inputHolder = inputHolder + userInput;
  20. userInput = (char)System.in.read();
  21.  
  22. }
  23. System.in.read();
  24.  
  25. // Converting chars input to integer
  26. int theId = Integer.parseInt(inputHolder);
  27.  
  28. // Executing for loop to match user Input to the correct movie title and ID
  29. for(x = 0; x < movieId.length; ++x)
  30. {
  31.  
  32. if(theId == movieId[x])
  33. {
  34. System.out.println("Id number " + theId + " matches movie title " + movieTitle[x]);
  35. }
  36. }
  37. }
  38. }
Reputation Points: 17
Solved Threads: 8
Junior Poster in Training
Banderson is offline Offline
66 posts
since Aug 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: URGENT - Reading from txt file into a 2 dimension array
Next Thread in Java Forum Timeline: required technical guidence for Struts and XML





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC