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

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

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]);
	   }
     }
   }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.