Create a program that will help a movie goer know which movie ratings will be ap
ID: 3535609 • Letter: C
Question
Create a program that will help a movie goer know which movie ratings will be appropriate for them or their family. Allow the user to enter an age and then based on that age suggest movie ratings that are most appropriate for them. G rated films are appropriate for everyone. PG should be suggested for anyone above age 5. PG-13 should be suggested for anyone at least 13 years old. R should be suggested for anyone at least 17 years of age. Inform anyone under 17 that they will not be able to even purchase a ticket for a rated R movie without an accompanying adult.
Develop the following program in Java with a single class which has a main method in it. The program should prompt the user for his or her age (or their children's age) as a whole number. Based on this age, the program should suggest all the movie ratings that would be appropriate based on this age. Display these movie ratings to the user. Then ask the user if he or she would like to check for someone else. If they answer 'Yes' then ask them the question again. If they answer 'No' the program should end. You will need to use some type of if statement to check for different ages. You will need a loop to allow the user to check for someone else.
Example:
Enter the age of the person watching the film (or your child's age if they will be seeing the movie with you): 12
G and PG movies are suggested for this age. You are not eligible to watch a R movie without an accompanying adult.
Would you like to check for someone else (Yes or No): Yes
Enter the age of the person watching the film (or your child's age if they will be seeing the movie with you): 15
G, PG, and PG13 movies are suggested for this age. You are not eligible to watch a R movie without an accompanying adult.
Would you like to check for someone else (Yes or No): Yes
Enter the age of the person watching the film (or your child's age if they will be seeing the movie with you): 22
G, PG, PG13, and R movies are suggested for this age.
Would you like to check for someone else (Yes or No): No
Explanation / Answer
import java.util.*;
class Main
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
String str;
do
{
System.out.println("Enter the age of the person watching the film (or your child's age if they will be seeing the movie with you): ");
int k = in.nextInt();
if(k<5)
System.out.println("G movies are suggested for this age. You are not eligible to watch a R movie without an accompanying adult.");
else if(k<13)
System.out.println("G and PG movies are suggested for this age. You are not eligible to watch a R movie without an accompanying adult.");
else if(k<17)
System.out.println("G ,PG and PG13 movies are suggested for this age. You are not eligible to watch a R movie without an accompanying adult.");
else if(k>17)
System.out.println("G ,PG, PG13 and R movies are suggested for this age. ENJOY. ");
System.out.println("Would you like to check for someone else (Yes or No): ");
str = in.next();
}while(str.equalsIgnoreCase("yes"));
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.