121k views
0 votes
rite a function to prompt the user to enter the information for one movie (title, release date, mpaa rating and number of stars). This function should then return the movie information back to main. You should call this function twice, once for each of the MovieInfo variables in main.

User R K Punjal
by
4.6k points

1 Answer

4 votes

Answer:

import java.util.*;

public class Movie {

public static void main (String [] args) {

System.out.println(movieInfo());

}

public static String movieInfo() {

Scanner input = new Scanner(System.in);

Scanner input2 = new Scanner(System.in);

System.out.print("Enter the title: ");

String title = input.nextLine();

System.out.print("Enter the release date: ");

String releaseDate = input.nextLine();

System.out.print("Enter the mpaa rating: ");

double mpaaRating = input2.nextDouble();

System.out.print("Enter the number of stars: ");

double numberOfStars = input2.nextDouble();

return "Title: "+title+ "\\Release Date: "+releaseDate+ "\\MPAA Rating: "+ mpaaRating+ "\\Number of Stars: "+numberOfStars;

}

}

Step-by-step explanation

- Create a function called movieInfo() that returns a string, information about a movie

- Ask the user to enter the title, release date, mpaa rating and number of stars of the movie.

- Return these values at the end of the function

- Inside the main, call the function to see the information about the movie

User Infojunkie
by
4.3k points