Question

Lab Exercise 5.2 Instructions: Name the program toMoviesYourLastNameFirstInitialLE52.java. The ...

Lab Exercise 5.2 Instructions: Name the program toMoviesYourLastNameFirstInitialLE52.java.

  1. The only class variable will be for the Scanner class.

  2. setMovieTitle(): Prompts for the title of the movie, and returns it from the keyboard.

  3. setYearReleased(): Prompts for the year in which the movie was released, and

    returns it from the keyboard.

  4. setMovieGenre(): Prompts for the type or category of the movie: action, animation,

    comedy, crime, documentary, drama, and returns it from the keyboard.

  5. setTicketPrice(): Prompts for the price of a movie ticket, and returns it from the

    keyboard.

  6. setProductionBudget(): Prompts for the movie’s production budget, and returns it

    from the keyboard.

  7. calcTicketSales(): Receives the production budget and the ticket price, and returns

    the number of tickets to be sold to break-even.

  8. displayMovieInfo(): Receives the ticket price, movie title, year released, movie

    genre, production budget, and the number of tickets to be sold to break-even.

  9. Consider clearing the buffer one time, and only in the main().

  10. In the main(): Call the methods in the order listed.

    1. setMovieTitle() and stores the returned value in a local variable. Example:

      localVar = methodName();

    2. setYearReleased() and stores the returned value in a local variable.

    3. setMovieGenre() and stores the returned value in a local variable.

    4. setTicketPrice() and stores the returned value in a local variable.

    5. setProductionBudget() and stores the returned value in a local variable.

    6. displayMovieInfo() by sending it as arguments the local variables for the ticket

      price, movie title, year released, movie genre, movie budget, and a call to calcTicketSales(). Example: methodName1(arg1, arg2, arg3, arg4, arg5, methodName2(arg7, arg8));

      Sample Output:

      Enter the movie title: How to Train Your Dragon: The Hidden World Enter the movie's release year: 2019
      Enter the movie's genre: Animation
      Enter the price of a movie ticket: 9

      Enter the movie's production budget without the trailing zeroes, e.g. $5,000,000 is entered as 5: 129

      MOVIE BREAK-EVEN POINT IN TICKETS ****Basis: $9.00 per Ticket****

      //This prompt is separated into //2 lines.

      Movie: How to Train Your Dragon: The Hidden World Year Released: 2019
      Genre: Animation
      Production Budget: $129.0 million

      Break-Even Ticket Sales: 14,333,333

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.text.NumberFormat;
import java.util.Scanner;

public class MoviesReview {
  
private static Scanner sc;
  
public static void main(String[] args)
{
// input and set movie title
String movieTitle = setMovieTitle();
  
// input and set movie release year
String yearReleased = setYearReleased();
  
// input and set movie genre
String movieGenre = setMovieGenre();
  
// input and set movie ticket price
double ticketPrice = setTicketPrice();
  
// input and set movie production budget
double productionBudget = setProductionBudet();
  
// display movie details
displayMovieInfo(movieTitle, yearReleased, movieGenre, ticketPrice
, productionBudget, calcTicketSales(productionBudget, ticketPrice));
}
  
public static String setMovieTitle()
{
System.out.print("Enter the movie title: ");
sc = new Scanner(System.in);
return sc.nextLine();
}
  
public static String setYearReleased()
{
System.out.print("Enter the movie's release year: ");
sc = new Scanner(System.in);
return sc.nextLine();
}
  
public static String setMovieGenre()
{
System.out.print("Enter the movie's genre: ");
sc = new Scanner(System.in);
return sc.nextLine();
}
  
public static double setTicketPrice()
{
System.out.print("Enter the price of a movie ticket: ");
sc = new Scanner(System.in);
return sc.nextDouble();
}
  
public static double setProductionBudet()
{
System.out.print("Enter the movie's production budget withourt the trailin zeros, e.g. $5,000,000 is entered as 5: ");
sc = new Scanner(System.in);
return sc.nextDouble();
}
  
public static int calcTicketSales(double productionBudget, double ticketPrice)
{
return (int)((productionBudget * 1000000) / ticketPrice);
}
  
public static void displayMovieInfo(String title, String releaseYear, String genre
, double ticketPrice, double productionBudget, int breakEvenTicketSales)
{
// format break-even ticket sales value separated by commas
//with a group of 3 from the right
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setGroupingUsed(true);
  
System.out.println("\n\nMOVIE BREAK-EVEN POINTS IN TICKETS\n"
+ "***** Basis: $" + String.format("%.2f", ticketPrice) + " per Ticket *****\n");
System.out.println("Movie: " + title
+ "\nYear Released: " + releaseYear
+ "\nGenre: " + genre
+ "\nProduction Budget: " + String.format("%.1f", productionBudget) + " million"
+ "\nBreak-Even Ticket Sales: " + numberFormat.format(breakEvenTicketSales));
}
}

******************************************************** SCREENSHOT *******************************************************************Output RockPaperScissors (run) Enter the movie title: How to train your dragon Enter the movies release year: 2019 Enter the

Add a comment
Know the answer?
Add Answer to:
Lab Exercise 5.2 Instructions: Name the program toMoviesYourLastNameFirstInitialLE52.java. The ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Purpose: To learn how to create and use stand-alone class programs (classes withouta main method)...

    LE 7.2 Purpose: To learn how to create and use stand-alone class programs (classes withouta main method). When you take code out of the application class and put it in a class of its own, you make it reusable Prep Work: Chapter 7 Figure 7.6 shows you how an application class uses the services of a Java class in Figure 7.5. Although the code for LE 7.2 is different than the code in these figures, the concept is the same....

  • WONT COMPILE ERROR STRAY / TEXT.H AND CPP PROGRAM SAYING NOT DECLARED HAVE A DRIVER WILL...

    WONT COMPILE ERROR STRAY / TEXT.H AND CPP PROGRAM SAYING NOT DECLARED HAVE A DRIVER WILL PASTE AT BOTTOM MOVIES.CPP #include "movies.h" #include "Movie.h" Movies *Movies::createMovies(int max) { //dynamically create a new Movies structure Movies *myMovies = new Movies; myMovies->maxMovies = max; myMovies->numMovies = 0; //dynamically create the array that will hold the movies myMovies->moviesArray = new Movie *[max]; return myMovies; } void Movies::resizeMovieArray() { int max = maxMovies * 2; //increase size by 2 //make an array that is...

  • Need help for C program. Thx #include <stdio.h> #include <string.h> #include <ctype.h> // READ BEFORE YOU...

    Need help for C program. Thx #include <stdio.h> #include <string.h> #include <ctype.h> // READ BEFORE YOU START: // This homework is built on homework 06. The given program is an updated version of hw06 solution. It begins by displaying a menu to the user // with the add() function from the last homework, as well as some new options: add an actor/actress to a movie, display a list of movies for // an actor/actress, delete all movies, display all movies,...

  • Using an object-oriented approach, write a program to read a file containing movie data (Tile, Director,...

    Using an object-oriented approach, write a program to read a file containing movie data (Tile, Director, Genre, Year Released, Running Time) into a vector of structures and perform the following operations: Search for a specific title Search for movies by a specific director Search for movies by a specific genre Search for movies released in a certain time period Search for movies within a range for running time Display the movies on the screen in a nice, easy to read...

  • For this lab you will write a Java program that plays the dice game High-Low. In...

    For this lab you will write a Java program that plays the dice game High-Low. In this game a player places a bet on whether the sum of two dice will come up High (totaling 8 or higher), Low (totaling 6 or less) or Sevens (totaling exactly 7). If the player wins, they receive a payout based on the schedule given in the table below: Choice Payout ------ ------ High 1 x Wager Low 1 x Wager Sevens 4 x...

  • Java Program Note: no break statements or switch staements High, Low, Sevens For this lab you...

    Java Program Note: no break statements or switch staements High, Low, Sevens For this lab you will write a Java program that plays the dice game High-Low. In this game a player places a bet on whether the sum of two dice will come up High (totaling 8 or higher), Low (totaling 6 or less) or Sevens (totaling exactly 7). If the player wins, they receive a payout based on the schedule given in the table below: Choice Payout ------...

  • In Java Burdell and the Buzz Problem Description As an aspiring band manager, you need to...

    In Java Burdell and the Buzz Problem Description As an aspiring band manager, you need to promote your band and expand publicity. Being hip with the times, you know that social media can make or break a band’s popularity. So, you decide to bring some ‘lucky’ Georgia Tech students to spread the good word! Solution Description Write the Concert, Musician, and Fan classes to guide your band on their rock star journey. You will design these classes from scratch following...

  • Lab Objectives Be able to write methods Be able to call methods Be able to declare...

    Lab Objectives Be able to write methods Be able to call methods Be able to declare arrays Be able to fill an array using a loop Be able to access and process data in an array Introduction Methods are commonly used to break a problem down into small manageable pieces. A large task can be broken down into smaller tasks (methods) that contain the details of how to complete that small task. The larger problem is then solved by implementing...

  • Lab 6 Instructions Objectives: • Executing and experimenting with programs that handle array related topics such...

    Lab 6 Instructions Objectives: • Executing and experimenting with programs that handle array related topics such as declaration, initialization, storing, retrieving, and processing elements. • Effectively manipulating and using ArrayList objects. • Becoming familiar with the use of arrays as method arguments and how array elements are passed to and returned from the called method. • Mastering the use of various debugging tools available on the Eclipse IDU. Important: EVERY one of the following Activities MUST be in a separate...

  • SYNOPSIS The product manager for coffee development at Kraft Canada must decide whether to introduce the...

    SYNOPSIS The product manager for coffee development at Kraft Canada must decide whether to introduce the company's new line of single-serve coffee pods or to await results from the product's launch in the United States. Key strategic decisions include choosing the target market to focus on and determining the value proposition to emphasize. Important questions are also raised in regard to how the new product should be branded, the flavors to offer, whether Kraft should use traditional distribution channels or...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT