954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Sorting Video titles using a ID numbers

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

eboney
Newbie Poster
1 post since Sep 2004
Reputation Points: 10
Solved Threads: 0
 

You could use a database and sql to query all that you want.

nanosani
Unauthenticated Liar
Team Colleague
1,830 posts since Jul 2004
Reputation Points: 45
Solved Threads: 56
 

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.

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]);
	   }
     }
   }
}
Banderson
Junior Poster in Training
66 posts since Aug 2004
Reputation Points: 17
Solved Threads: 8
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You