[solved]-Create Program Called Tickets3java Input User Command Line Use Scanner Object Need Create Q39047781
Create a program called Tickets3.java.
All the input from the user should be from the command line (usethe Scanner object). You only need to create one Scanner object tohandle all the input.
Do not use JOptionPane.
Methods are a way to break apart a complex program into smallerpieces. In this assignment, you will modify your previous US OpenTickets Assignment 2 to enclose the different parts of your programinside methods
assignment 2:
import java.util.Scanner;public class ConTickets2 { private static final double AuthurAshe = 450.25; private static final double LouisArmstrong = 225.75; private static final double Grandstand = 175.50; public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out .print(“Enter A, L, or G (1 for Authur Ashe, 2 for Louis Armstrong & 3 for Grandstand): “); int type = input.nextInt(); System.out.print(“Enter number of tickets: “); double tickets = input.nextDouble(); input.close(); double total = 0.0d; // switching by type switch (type) { case 1: total = tickets * AuthurAshe; break; case 2: total = tickets * LouisArmstrong; break; case 3: total = tickets * Grandstand; break; default: // any other (invalid) total = 0; } // displaying price formatted to 2 digits after decimal point System.out.printf(“nYour day of amazing tennis will cost: $%.2fn”, total); }}
Your main method will call five methods: displayPrices(),getStadium(), getNumTickets(), calculatePrice(), anddisplayTotal(). There should be nothing else in the mainmethod besides calls to these methods and a few variabledeclarations.
The method displayPrices() will display to the user the pricesfor the tickets.
The method getStadium() will return the value the user enters.If the value is not one of the valid values (generally 1, 2, or 3if you used ints, ‘A’, ‘L’, ‘G’ if you used chars), tell the userto re-enter a value. Use a while loop that will continue to loop ifthe user does NOT enter a valid value. Since you have put the pricelist into the method displayPrices(), call that method from thismethod if the user did not enter a valid value. This method shouldreturn the int or char – your choice – that indicates the user’sselection.
The method getNumTickets() will ask the user the number oftickets being purchased and return the value. Similar to thegetStadium() method, this method should not accept bad data. Thenumber should be between 1 and 10 inclusive (meaning 1 and 10 arevalid values). This method will return an int since you cannotpurchase a fractional number of tickets.
The method calculatePrice() will define two parameters, stadiumand numTickets. The parameter stadium will be either be a char oran int depending on what was returned from getStadium(). Theparameter numTickets will be an int because getNumTickets()returnsan int. This method will calculate the price of the tickets andreturn it as a double. It is in this method that you will put theswitch statement from the previous assignment. This method willreturn the price of the tickets as a double.
The method displayTotal() will define one parameter, a double,and display the total price. The value sent to this method will bethe value that was returned from calculatePrice().
The method headers:
public static void displayPrices()
public static char getStadium()
or public static int getStadium()
public static int getNumTickets()
public static double calculatePrice(int, int)
or public static double calculatePrice(char, int)
public static void displayTotal(double)
Notes:
- Format the dollar amounts properly using printf. The dollaramounts should have two numbers after the decimal point.
- All methods need to start with public static
- To simplify the program, declare the Scanner object inside theclass but outside the methods as shown below. It should be thefirst statement in the class, before the main method. All themethods will have access to it.
static Scanner keyboard = new Scanner(System.in);
Expert Answer
Answer to Create a program called Tickets3.java. All the input from the user should be from the command line (use the Scanner obje… . . .
OR

