Question

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

**SAMPLE OUTPUT - EXCEPT FOR SLIGHT DIFFERENCE IN ORDER OF PROMPTS, EXACTLY SAME AS LE 5.2**** Enter the movie title: How to

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. Lab Exercise 7.2 Instructions: Relocate the code for LE 5.2 in a separate class file without a main(). Name the class Movies. In this class, 1. Code a no-args (empty) constructor. 2. Copy only the Scanner input as the field from LE 5.2. The field is to be private and non-static (i.e., leave out the word "static") 3. Copy all the methods from LE 5.2, except for the main() 4. Make the methods non-static 5. Be attentive to your import statement(s) In a separate file called YourLastNameFirstlnitialLE72.java, copy the main() from LE 5.2. Store this file in the same location as the Movies.java file. In the main() 1. Instantiate an obiect of the Movies class 2. You'll use the empty constructor for the Movies class to create the object. 3. Use the object to call the methods, but call the setMovieGenre() right after setMovieTitle() to avoid implementing an empty call to input.nextLine() 4. Don't forget to end the main) with an exit statement 5. So except for instantiating the Movies class object, all the code from the main) in LE 5.2 is the same other than using the object to call the methods and the slight difference in the order of the method calls 6. Be attentive to your import statement(s) ProgramName reference VariableName new ProgramName); referenceVariableName.methodName() Grading Requirements: During lab class, enter your name on the sign-up sheet for grading when your assignment is in gradable condition Assignment © Linda Shepherd
**SAMPLE OUTPUT - EXCEPT FOR SLIGHT DIFFERENCE IN ORDER OF PROMPTS, EXACTLY SAME AS LE 5.2**** Enter the movie title: How to Train Your Dragon: The Hidden World Enter the movie's genre: Animation Enter the movie's release year: 2019 Enter the price of a movie ticket: 9 Enter the movie's production budget without theI/This prompt is separated into trailing zeroes, e.g. $5,000,000 is entered as 5: 129 I/2 lines MOVIE BREAK-EVEN POINT IN TICKETS Basis: $9.00 per Ticket" 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

/********************************Movie.java***************************/

import java.util.Scanner;

public class Movie {

   private String movieTitle;
   private String genre;
   private String releaseYear;
   private double priceTicket;
   private double budget;
   public Movie() {
      
   }
  
   public void inputData(Scanner scan) {
       System.out.print("Enter the movie title:");
       movieTitle = scan.nextLine();
       System.out.print("Enter the movie's Genre: ");
       genre = scan.nextLine();
       System.out.print("Enter the Movie's release year: ");
       releaseYear = scan.nextLine();
       System.out.print("Enter the price of movie ticket: ");
       priceTicket = scan.nextDouble();
       System.out.print("Enter the movie's production budget without the\ntrailing Zeroes, e.g. $5,000,000 is entered as 5: ");
       budget = scan.nextDouble();
       scan.close();
   }
  
   public void printData() {
      
       System.out.println("\nMOVIE BREAK-EVEN POINT IN TICKETS\n***Basis: $"+priceTicket+" per Ticket****\n");
       System.out.println("Movie: "+movieTitle);
       System.out.println("Year Released: "+releaseYear);
       System.out.println("Genre: "+genre);
       System.out.println("Production Budget: $"+budget+" million");
       System.out.println("Break-Even Ticket Sales: "+(int)((budget*100000)/priceTicket));
      
   }
  
}
/**********************************YourLastNameFirstInitialLE.java***************************/

import java.util.Scanner;

public class YourLastNameFirstInitialLE72 {

   public static void main(String[] args) {
      
       Movie movie = new Movie();
       Scanner Scan = new Scanner(System.in);
       movie.inputData(Scan);
       movie.printData();
   }
}
/************************output*****************************/

Enter the movie title:How to Train Your Dragon: The Hidden World
Enter the movie's Genre: Animation
Enter the Movie's release year: 2019
Enter the price of 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.0 per Ticket****

Movie: How to Train Your Dragon: The Hidden World
Year Released: 2019
Genre: Animation
Production Budget: $129.0 million
Break-Even Ticket Sales: 1433333

B ConsoleX <terminated> YourLastNameFirstlnitialLE72 [Java Application] C:\Program FilesJava\jre1 Enter the movie title:How t

Thanks a lot, Please let me know if you have any problem................

Add a comment
Know the answer?
Add Answer to:
Purpose: To learn how to create and use stand-alone class programs (classes withouta main method)...
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
  • Lab Exercise 5.2 Instructions: Name the program toMoviesYourLastNameFirstInitialLE52.java. The ...

    Lab Exercise 5.2 Instructions: Name the program toMoviesYourLastNameFirstInitialLE52.java. The only class variable will be for the Scanner class. setMovieTitle(): Prompts for the title of the movie, and returns it from the keyboard. setYearReleased(): Prompts for the year in which the movie was released, and returns it from the keyboard. setMovieGenre(): Prompts for the type or category of the movie: action, animation, comedy, crime, documentary, drama, and returns it from the keyboard. setTicketPrice(): Prompts for the price of a movie ticket,...

  • Help! Not sure how to create this java program to run efficiently. Current code and assignment...

    Help! Not sure how to create this java program to run efficiently. Current code and assignment attached. Assignment :Write a class Movies.java that reads in a movie list file (movies.txt). The file must contain the following fields: name, genre, and time. Provide the user with the options to sort on each field. Allow the user to continue to sort the list until they enter the exit option. ---------------------------------------------------------- import java.util.*; import java.io.*; public class Movies { String movieTitle; String movieGenre;...

  • LE 7.1 Create a separate class called Family. This class will have NO main(). Insert a...

    LE 7.1 Create a separate class called Family. This class will have NO main(). Insert a default constructor in the Family class. This is a method that is empty and its header looks like this: public NameOfClass() Except, for the main(), take all the other methods in LE 6.2 and put them in the Family class. Transfer the class variables from LE 6.2 to Family. Strip the word static from the class variables and the method headers in the Family...

  • IS 2031: LE 7.1 Lab Day DUE D M 4/22/19 Sections 001, 002, 003 Purpose: To...

    IS 2031: LE 7.1 Lab Day DUE D M 4/22/19 Sections 001, 002, 003 Purpose: To learn how to create a class, instantiate an object of the class in another class, and use that object to call methods. Prop Work: Read chapter 7. Refer to coding created or reviewed in your IS 2033 class. Lab Exercise 7.1 Instructions: Name your program as YourLastNameFirstinitialLE71 java. From the code in LE 6.2, do the following: 1. You will NOT be changing any...

  • MEDIA INHERITANCE - C++ You will create an inheritance set of classes. Use proper rules for...

    MEDIA INHERITANCE - C++ You will create an inheritance set of classes. Use proper rules for data types, class definitions, and inheritance (check input/output of data below). You will create a super media class that will define a general form of media. A media properties will consist of the name and price. The media should be able to construct itself out of the arguments sent to it, virtually print both data fields labeled (price to two decimal places) and overload...

  • Create a CalculatorTest class that contains the main method. 1. Get two double numbers as input...

    Create a CalculatorTest class that contains the main method. 1. Get two double numbers as input and create an object of the ScientificCalculator Class with those two numbers. 2. Then call the 8 operations one by one sequentially and display the result. Code must be written in Java. (Sample input/output: Enter number 1: 2 Enter number 2: 3 Add() result is : 5 Sub() result is: -1 ……. Power() result is: 8 …… sqrtNum1 result is:) The Problem: Given the...

  • MUST BE WRITTEN IN C++ Objective: Learn how to define structures and classes, create and access...

    MUST BE WRITTEN IN C++ Objective: Learn how to define structures and classes, create and access a vector of structures, use sort with different compare functions. Assignment: Your program will use the same input file, but you will print the whole book information, not just the title. And, most importantly, this time you will take an object oriented approach to this problem. Detailed specifications: Define a class named Collection, in which you will define a structure that can hold book...

  • MUST BE WRITTEN IN C++ Objective: Learn how to define structures and classes, create and access...

    MUST BE WRITTEN IN C++ Objective: Learn how to define structures and classes, create and access a vector of structures, use sort with different compare functions. Assignment: Your program will use the same input file, but you will print the whole book information, not just the title. And, most importantly, this time you will take an object oriented approach to this problem. Detailed specifications: Define a class named Collection, in which you will define a structure that can hold book...

  • Queues and Stacks Purpose: To review queues and stacks in Java, and to use the built-in...

    Queues and Stacks Purpose: To review queues and stacks in Java, and to use the built-in Stack class and Queue interface. The Stack class is a generic class containing these methods: public void push(E value) - pushes a new value onto the Stack public E pop() - pops the next value off of the stack and returns it; throws EmptyStackExceptionl if stack is empty public E peek() - returns the next value on the Stack but does not pop it...

  • C++ program Correctly complete the following assignment. Follow all directions. The main purpose is to show...

    C++ program Correctly complete the following assignment. Follow all directions. The main purpose is to show super and sub class relationships with an array of super media pointers to sub class objects and dynamic binding. The < operator will be overloaded in the super class so all subclasses can use it. The selection sort method will be in the main .cpp file because it will sort the array created in main. The final .cpp file, the three .h header class...

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