Question: how can I make this method work without changing the variables import java.util.Scanner; public class ParallelArrayMovies { public static final String DATAFILE = .

how can I make this method work without changing the variables
import java.util.Scanner;
public class ParallelArrayMovies {
public static final String DATAFILE="../data/movielist.txt";
public static final int MAXMOVIES=10000;
public static void main(String [] args){
int choice; // user's selection from the menu
String [] titles= new String[MAXMOVIES];
String [] genres= new String[MAXMOVIES];
int [] years= new int[MAXMOVIES];
int numberOfEntries;
titles[0]=("Dr.No");
genres[0]=("Rmomance");
years[0]=1962;
titles[1]=("From Russia with Love");
genres[1]=("Action");
years[1]=1963;
titles[2]=("Agent 353- Pasport to Hell");
genres[2]=("Horror");
years[2]=1964;
numberOfEntries= loadMovies(titles,genres,years);
numberOfEntries++;
System.out.println("Number of entries read from data file: "+numberOfEntries);
do {
choice= getMenuChoice();
if (choice==1)
numberOfEntries= enterMovie(titles,genres,years,numberOfEntries);
else if (choice==2)
//DeleteaMovie(titles,genres,years,numberOfEntries);
//else if (choice==3)
displayAll(titles,genres,years,numberOfEntries);
//else if (choice==4)
//searchbyTitle(titles,genres,years,numberOfEntries);
else if (choice==5)
searchByGenre(titles,genres,years,numberOfEntries);
else if (choice==6)
searchByYear(titles,genres,years,numberOfEntries);
} while (choice!=0);
System.out.println("
THE END");
}
/**
* Allow user to enter a new movie.
*
* @param titles array of movie titles
* @param genres array of movie genres
* @param years array of movie copyright dates
* @param n the actual number of movies currently in the array
* @return the new movie count
*/
public static int enterMovie(String [] titles, String [] genres, int [] years, int n){
Scanner kb= new Scanner(System.in);
System.out.print("Enter movie title : ");
titles[n]= kb.nextLine();
System.out.print("Enter movie genre: ");
genres[n]= kb.nextLine();
System.out.print("Enter year of movie: ");
years[n]= kb.nextInt();
kb.nextLine();
return n+1;
}
public static int loadMovies(String [] titles, String [] genres, int [] years){
return 0;
}
public static void displayAll(String [] titles, String [] genres, int [] years, int n){
int i;
System.out.println("------------------------------------------------");
System.out.printf("%-30s %-20s %s
","TITLE","GENRE","YEAR");
for (i=0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!