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

Write Java code to implement the following pseudocode: Create a new object of ty

ID: 3887898 • Letter: W

Question

Write Java code to implement the following pseudocode:

Create a new object of type Scanner that reads from the keyboard

Create a new movie object

Prompt the user to enter the title of a movie

Read in the line that the user types

Set the title in the movie object

Prompt the user to enter the movie’s rating

Read in the line that the user types

Set the rating in the movie object

Prompt the user to enter the number of tickets sold at a (unnamed) theater

Read in the integer that the user types

Set the number of tickets sold in the movie object

Print out the information using the movie’s toString method

This is what I have so far

import java.util.Scanner;

public class MovieDriver {

  

   public static void main(String[] args) {

      

       //Scanner object for input

       Scanner keyboard = new Scanner(System.in);

      

       int n; //Controls the Loop

      

   }

Explanation / Answer


import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;
class Movie
{
String title;
int rating, tic;
public String getTitle()
{
return title;
}
public int getRating()
{
return rating;
}
public int getTicketsold()
{
return tic;
}
public void setTitle(String title)
{
this.title = title;
}
public void setRating(int rating)
{
this.rating = rating;
}
public void setTicketsold(int tic)
{
this.tic = tic;
}
public String toString()
{
return "Title = " +title;
}
}
class MovieDriver
{
public static void main(String[] args)
{
Movie m = new Movie();
Scanner keyboard = new Scanner(System.in);
System.out.println(" Enter the Title of a movie: ");
String title = keyboard.nextLine();
System.out.println(" Enter the Rating of movie: ");
int rating = keyboard.nextInt();
System.out.println(" Enter Number of Ticket Sold: ");
int tic = keyboard.nextInt();
m.setTitle(title);
m.setRating(rating);
m.setTicketsold(tic);
System.out.println(" Movie Title: " +m.getTitle());
System.out.println(" Movie Rating: " +m.getRating());
System.out.println(" Movie Ticket Sold: " +m.getTicketsold());
}
}


OUTPUT


Enter the Title of a movie: Mersal
Enter the Rating of movie: 5
Enter Number of Ticket Sold: 500
Movie Title: Mersal
Movie Rating: 5
Movie Ticket Sold: 500

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