Question: I need help with my code, I'm struggling, please help rewrite. I ran out of room to post rest of code. package com.mycompany.wk8garciam; import java.util.Scanner;

I need help with my code, I'm struggling, please help rewrite. I ran out of room to post rest of code.

package com.mycompany.wk8garciam;

import java.util.Scanner;

abstract class Media { private final String id; private String title; private String yearPublished;

public Media(String id, String title, String yearPublished) { this.id = id; this.title = title; this.yearPublished = yearPublished; }

public abstract double calculateRentalFee(); public abstract void display(); public void setTitle(String title) { this.title = title; }

public void setYearPublished(String yearPublished) { this.yearPublished = yearPublished; }

public String getId() { return id; }

public String getTitle() { return title; }

public String getYearPublished() { return yearPublished; } }

class EBook extends Media { private final int numberOfChapters;

public EBook(String id, String title, String yearPublished, int numberOfChapters) { super(id, title, yearPublished); this.numberOfChapters = numberOfChapters; }

@Override public double calculateRentalFee() { double fee = numberOfChapters * 0.10 + 1.50; if (Integer.parseInt(getYearPublished()) > 2015) { fee += 1.00; } return fee; }

@Override public void display() { System.out.println("ID: " + getId()); System.out.println("Title: " + getTitle()); System.out.println("Year Published: " + getYearPublished()); System.out.println("Number of Chapters: " + numberOfChapters); System.out.println("Rental Fee: $" + calculateRentalFee()); } }

class MusicCD extends Media { private final int lengthInMinutes;

public MusicCD(String id, String title, String yearPublished, int lengthInMinutes) { super(id, title, yearPublished); this.lengthInMinutes = lengthInMinutes; }

@Override public double calculateRentalFee() { double fee = lengthInMinutes * 0.045 + 1.50; if (Integer.parseInt(getYearPublished()) > 2014) { fee += 2.00; } return fee; }

@Override public void display() { System.out.println("ID: " + getId()); System.out.println("Title: " + getTitle()); System.out.println("Year Published: " + getYearPublished()); System.out.println("Length in Minutes: " + lengthInMinutes); System.out.println("Rental Fee: $" + calculateRentalFee()); } }

class MovieDVD extends Media { private int durationInMinutes; private String genre;

public MovieDVD(String id, String title, String yearPublished, int durationInMinutes, String genre) { super(id, title, yearPublished); this.durationInMinutes = durationInMinutes; this.genre = genre; }

@Override public double calculateRentalFee() { double fee = durationInMinutes * 0.03 + 2.50; if (Integer.parseInt(getYearPublished()) > 2010) { fee += 1.00; } return fee; }

@Override public void display() { System.out.println("ID: " + getId()); System.out.println("Title: " + getTitle()); System.out.println("Year Published: " + getYearPublished()); System.out.println("Duration in Minutes: " + durationInMinutes); System.out.println("Genre: " + genre); System.out.println("Rental Fee: $" + calculateRentalFee()); }

public int getDurationInMinutes() { return durationInMinutes; }

public void setDurationInMinutes(int durationInMinutes) { this.durationInMinutes = durationInMinutes; }

public String getGenre() { return genre; }

public void setGenre(String genre) { this.genre = genre; } }

I need help with my code, I'm struggling, please help rewrite. I

ran out of room to post rest of code. package com.mycompany.wk8garciam; import

java.util.Scanner; abstract class Media { private final String id; private String title;

System.out.println(x: "Enter rent status (true/false): "); boolean rentStatus = scanner. nextBoolean( ); scanner.nextLine( ); System. out. println( x :"Enter media model (E/C/D): "); char mediaModel = scanner. nextLine (),charAt( index: 0); System. out.println( x: "Enter title: "); String title = scanner.nextLine () ; System.out.println( x: "Enter year published: "); String yearPublished = scanner.nextLine( ); System. out. println( x: "Enter scope media: "); int scopeMedia = scanner.nextInt () ; scanner.nextLine( ); library. addMedia(mediaID, rentStatus, mediaModel, title, yearPublished, scopeMedia); break; case 2: System.out.println( x: "Enter media ID: "); mediaID = scanner. nextLine () ; library. cemoxeMedia (mediaID); break; case 3: System.out.println( x: "Enter media ID: "); mediaID = scanner. nextLine ( ); library. centMedia(mediaID); break; case 4: System.out.println( x: "Enter media ID: "); mediaID = scanner. nextLine ( ); library. modifyMedia (mediaID); break; case 5: System. out. println( x : "Exiting program"); break; default: System.out.println("Invalid choice:" + choice); break; le (choice !=5)

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!