Question
I know my code works as i have recieved screenshots of others running it, but i am unable to compile it through command prompt for
I know my code works as i have recieved screenshots of others running it, but i am unable to compile it through command prompt for some reason. I am required to use command prompt.
Lab7:
import java.util.*; import java.io.*; public class Lab7 { public static void main(String [] args) throws IOException { MovieDB movies = new MovieDB(10); // Create MovieDB object. The // size is set at 10, meaning it can hold up to 10 // movies. If we wanted (as discussed in lecture) we // could allow for it to be resized so it could hold // an arbitrary number of movies. loadData(movies); // input movie data from file getCommands(movies); // interact with user saveData(movies); // save movie data back to file } public static void loadData(MovieDB movies) throws IOException { // Note the syntax below for creating a Scanner to a file //Please change path to movieFile Scanner S = new Scanner(new FileInputStream("movieFile.txt")); // *** CODE SEGMENT 1 *** // // Complete this method in the following way: // Read in the number of movies from the file // For each movie read the data from the file and create a Movie // object // Add the Movie to the MovieDB object (movies) using the appropriate // method (see MovieDB class) int numMovies=Integer.parseInt(S.nextLine()); for(int i=0; i Movie: import java.text.*; import java.util.*; public class Movie { private String title; private String director; private String studio; private double gross; // Constructor -- take 4 arguments and make a new Movie public Movie(String t, String d, String s, double g) { title = new String(t); director = new String(d); studio = new String(s); gross = g; } // Return a formatted string version of this Movie public String toString() { StringBuffer B = new StringBuffer(); B.append("Title: " + title + " "); B.append("Director: " + director + " "); B.append("Studio: " + studio + " "); NumberFormat formatter = NumberFormat.getCurrencyInstance(Locale.US); B.append("Gross: " + formatter.format(gross) + " "); return B.toString(); } // Return an unformatted string version of this Movie public String toStringFile() { StringBuffer B = new StringBuffer(); B.append(title + " "); B.append(director + " "); B.append(studio + " "); B.append(gross + " "); return B.toString(); } // Accessor to return title of this Movie public String getTitle() { return title; } } MovieDB: import java.text.*; import java.util.*; public class Movie { private String title; private String director; private String studio; private double gross; // Constructor -- take 4 arguments and make a new Movie public Movie(String t, String d, String s, double g) { title = new String(t); director = new String(d); studio = new String(s); gross = g; } // Return a formatted string version of this Movie public String toString() { StringBuffer B = new StringBuffer(); B.append("Title: " + title + " "); B.append("Director: " + director + " "); B.append("Studio: " + studio + " "); NumberFormat formatter = NumberFormat.getCurrencyInstance(Locale.US); B.append("Gross: " + formatter.format(gross) + " "); return B.toString(); } // Return an unformatted string version of this Movie public String toStringFile() { StringBuffer B = new StringBuffer(); B.append(title + " "); B.append(director + " "); B.append(studio + " "); B.append(gross + " "); return B.toString(); } // Accessor to return title of this Movie public String getTitle() { return title; } } movieFile: 3 Star Wars George Lucas 20th Century Fox 7.98E8 Jaws Steven Spielberg Universal 4.706E8 The Return of the King Peter Jackson New Line 1.1292E9 My errors:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started