Question: **PLEASE HELP ME COMPLETE THIS QUESTION IN JAVA** 8.02) Create a class named Movie that can be used with your video rental business. The Movie

**PLEASE HELP ME COMPLETE THIS QUESTION IN JAVA**

8.02) Create a class named Movie that can be used with your video rental business. The Movie class should track the Motion Picture Association of America (MPAA) rating (e.g., Rated G, PG-13, R), ID Number, and movie title with appropriate accessor and mutator methods. Also create an equals() method that overrides Objects equals() method, where two movies are equal if their ID number is identical. Next, create three additional classes named Action, Comedy, and Drama that are derived from Movie. Finally, create an overridden method named calcLateFees that takes as input the number of days a movie is late and returns the late fee for that movie. The default late fee is $2/day. Action movies have a late fee of $3/day, comedies are $2.50/day, and dramas are $2/day. In main method, make one Movie class which is also Action, one that is also Comedy and one that is also Drama. Ask user to enter a movie ID and how many days it was late to display late fee.

**IT HAS TO FOLLOW THIS RESULT**:

EntermovietitleformovietypeAction:Furious7

Entermovieid:83824545

Entermovierating(G,PG,PG13,R,NC17):PG13

EntermovietitleformovietypeComedy:GetHard

Entermovieid:78522254

Entermovierating(G,PG,PG13,R,NC17):R

EntermovietitleformovietypeDrama:Titanic

Entermovieid:23555458

Entermovierating(G,PG,PG13,R,NC17):PG13

Entermovieidnumber:23555458

Enternumberofdaysmoviewaslate:2

Latefeefor23555458,movietypeDramais$4.0

**MY CODE**:

//Movie.java class Movie { //instance variables String rating; int idNumber; String movieTitle; // constructor Movie(String rating, int idNumber, String movieTitle){ this.rating=rating; this.idNumber=idNumber; this.movieTitle=movieTitle; }

// getter and setter public String getRating() { return rating; } public void setRating(String rating) { this.rating = rating; } public int getIdNumber() { return idNumber; } public void setIdNumber(int idNumber) { this.idNumber = idNumber; } public String getMovieTitle() { return movieTitle; } public void setMovieTitle(String movieTitle) { this.movieTitle = movieTitle; } // equal() overrides Objects equal() public boolean equals(Object o) { Movie checkIdNumber = (Movie)o;

return checkIdNumber.idNumber == idNumber; } // calculate LateFess float calcLateFees(int days){ float lateFees = 2; lateFees*=days; return lateFees; } // override toString() for displaying output public String toString(){ return "Rating="+getRating()+"\t"+"Id Number="+getIdNumber()+"\t"+"Movie title="+getMovieTitle(); }

}

class Action extends Movie{ Action(String rating, int idNumber, String movieTitle){ super(rating,idNumber,movieTitle); // inherits the super class properties } // overrides calculateFees() in Movie Class float calcLateFees(int days){ float lateFees = 3; lateFees*=days; return lateFees; } }

class Comedy extends Movie{ Comedy(String rating, int idNumber, String movieTitle){ super(rating,idNumber,movieTitle); } float calcLateFees(int days){ float lateFees = 2.50f; lateFees*=days; return lateFees; } }

class Drama extends Movie{ Drama(String rating, int idNumber, String movieTitle){ super(rating,idNumber,movieTitle); } float calcLateFees(int days){ float lateFees = 2; lateFees*=days; return lateFees; } }

class Tst{ public static void main(String args[]){ // creating objects Movie m1=new Comedy("PG",111,"housefull"); Movie m2=new Action("PG-13",222,"Action Jackson"); Movie m3=new Drama("R",333,"Kuch kuch hota hai"); Movie m4=new Movie("R",111,"bhootnath"); // getting values and passing arguments to calculate LateFees and checking duplicate Id Number System.out.println(m1.toString()+"\t"+"Id exists="+m1.equals(m3)+"\t"+"LateFees="+m1.calcLateFees(2)); System.out.println(m2.toString()+"\t"+"Id exists="+m2.equals(m3)+"\t"+"LateFees="+m2.calcLateFees(4)); System.out.println(m3.toString()+"\t"+"Id exists="+m3.equals(m3)+"\t"+"LateFees="+m3.calcLateFees(6)); System.out.println(m4.toString()+"\t"+"Id exists="+m4.equals(m1)+"\t"+"LateFees="+m4.calcLateFees(4));

} }

**Result**:

CODELAB ANALYSIS: LOGICAL ERROR(S)

Problems Detected: The contents of your standard output is incorrect.

Given the following was entered from the keyboard: Furious 7 83824545 PG13 Get Hard 78522254 R Titanic 23555458 PG13 ... you displayed: instead of: Enter movie title for movie type Action:Enter movie id:Enter movie rating (G, PG, PG13, R, NC17):Enter movie title for movie type Comedy:Enter movie id:Enter movie rating (G, PG, PG13, R, NC17):Enter movie title for movie type Drama:Enter movie id:Enter movie rating (G, PG, PG13, R, NC17): Enter movie id number:Enter number of days movie was late:Late fee for 23555458, movie type Dramais $4.0

**PLEASE HELP ME TO FIX THE CODE TO THE EXPECTED OUTPUT**

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!