Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The body of a function is a block of code, containing sequential instructions fo

ID: 3785619 • Letter: T

Question

The body of a function is a block of code, containing sequential instructions for the computer to execute. As with any other block, it may contain conditional statements and loop statements. The function you will write in this exercise uses conditions to do it's job.

Write a function called bad_critic that returns automatic hot take reviews of movies. This function takes two parameters, the length of the movie in minutes (an integer), and the MPAA rating (a string), returns a star rating (an integer) and passes back a review snippet (a string) by reference.

The function you write should follow these rules:

If the movie is less than 90 minutes, the review is "Rip off!" and the rating is 1.

If the movie is at least 150 minutes, and the rating is not "R", the review is "TL:DR" and the rating is 2.

If the movie is at least 150 minutes, and the rating is "R", the review is "Bloated summer fare", and the rating is 3.

But all "G" movies get the review "Fine for kids" and the rating 4.

All other movies at least 90 and less than 150 minutes get the review "Breathtaking" and the rating 5.

There is no user input or output in this problem! Nothing gets read from or written to the console here.

Explanation / Answer


// Java program for movie review and rating.

// Run this file in command or in any ide (e.g. Eclipse) by copy and pasting this in file rate_movie.java and run it.

public class rate_movie {
   static String review=null; // global variable to store review value.
  
   public static void main(String args[])
   {
      
  
       int movie_minutes[]={80,150,170,180,100,150}; // movie minutes defined.
       String MPAA[]={"Q", "P", "G", "R", "K", "R"}; // change the rating value here according to your need.

       for(int i=0; i<6; i++)
       {
          
      
       int star_rating=bad_critic(movie_minutes[i],MPAA[i]);
       System.out.println("The review for the movie of duration "+movie_minutes[i]+" with MPAA rating "+ MPAA[i] + " is "+ review+" and the rating is " + star_rating );
          
          
       }
   }
  
   //bad_critic method starts below to define review and rating values
  
   public static int bad_critic(int movie_min, String MPAA_review)   
   {
       int rating = 0;
      
       if(((MPAA_review.equals("G")==true)))
       {
           review = "Fine for kids";
           rating = 4;
       }
      
       else if(movie_min < 90)
       {
           review = "Rip off!";
           rating = 1;
          
       }

       else if(movie_min>=90 && movie_min<150)
       {
           review = "Breathtaking";
           rating =5;
       }
      
       else if(movie_min>=150 && ((MPAA_review.equals("R")==false)))
       {
               review ="TL:DR";
               rating = 2;
              
       }
      
       else if(movie_min>=150 && ((MPAA_review.equals("R")==true)))
       {
               review = "Bloated summer fare";
               rating = 3;
              
       }
      
       return rating;
      
   }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote