Sorting Video titles using a ID numbers

Reply

Join Date: Sep 2004
Posts: 1
Reputation: eboney is an unknown quantity at this point 
Solved Threads: 0
eboney eboney is offline Offline
Newbie Poster

Sorting Video titles using a ID numbers

 
0
  #1
Sep 20th, 2004
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 1,749
Reputation: nanosani is an unknown quantity at this point 
Solved Threads: 55
Team Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: Sorting Video titles using a ID numbers

 
0
  #2
Sep 21st, 2004
You could use a database and sql to query all that you want.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 47
Reputation: Banderson is an unknown quantity at this point 
Solved Threads: 4
Banderson's Avatar
Banderson Banderson is offline Offline
Light Poster

Re: Sorting Video titles using a ID numbers

 
0
  #3
Oct 4th, 2004
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.

  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. }
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC