Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Movie { private String name; private double rating; private double length; private boolean wonOscar; public Movie() { name = ; rating = 0;

public class Movie { private String name; private double rating; private double length; private boolean wonOscar;

public Movie() { name = ""; rating = 0; length = 0; wonOscar = false; }

public Movie(String name, double rating, double length, boolean wonOscar) { this.name = name; this.rating = rating; this.length = length; this.wonOscar = wonOscar; }

public String getName() { return name; }

public void setName(String name) { this.name = name; }

public double getRating() { return rating; }

public void setRating(double rating) { this.rating = rating; }

public double getLength() { return length; }

public void setLength(double length) { this.length = length; }

public boolean getWonOscar() { return wonOscar; }

public void setWonOscar(boolean wonOscar) { this.wonOscar = wonOscar; } ------------------------- public static void main(String[] args) { // Exercise 1 Movie m1 = new Movie("Shutter Island", 8.2, 2.18, false); Movie m2 = new Movie("The Intouchables", 8.5, 1.52, true); Movie m3 = new Movie("Me Before You", 7.4, 1.47, true); System.out.println(m1.getName()); System.out.println(m2.getName()); System.out.println(m3.getName()); // Exercise 2 if (m1.getRating() >= m2.getRating() && m1.getRating() >= m3.getRating() && m1.getWonOscar()) { System.out.println(m1.getName()); } else if(m2.getRating() >= m1.getRating() && m2.getRating() >= m3.getRating() && m2.getWonOscar()) { System.out.println(m2.getName()); } else if(m3.getRating() >= m1.getRating() && m3.getRating() >= m2.getRating() && m3.getWonOscar()) { System.out.println(m3.getName()); } Exercise 2: Print the name of the movie which has the highest rating among the 3 movies and won an Oscar.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions