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

Please help with the code for this assignment in my Java class! I have no idea w

ID: 3691095 • Letter: P

Question

Please help with the code for this assignment in my Java class! I have no idea what to do...

CSE 110-Assignment #8 Maximum Points: 20 What this Assignment Is About . 2-D array . Searching UML diagram . Reading from files Things to check when implementing classes: Instance variables should be declared as private . Methods and constructors are declared public Use uppercase for classes. Use lower case with uppercase word separators for all other identifiers (variables, methods, objects) . Use tabs or spaces to indent code within blocks (code surrounded by braces). This includes classes, methods, and code associated with ifs, switches and loops. Be consistent with the number of spaces or tabs that you use to indent. Use comments to give a description of each method Use comments after the ending brace of classes, methods, and blocks to identify to which block it belongs Part 2: Programming: (20 points) Your assignment is to design a TicketManager class that can keep track of the number of seats available in a theater's auditorium. The TicketManager class should have a two-Dimensional array, which has 15 rows and 30 columns for all the seats available in the auditorium, also an array of double to keep track of the price of tic for each row. Each row has a different price. Use the following UML diagram to design the class: kets TicketMana + NUMROWS : static final int= 15 +NUMCOLUMNS : static final int = 30 -seats[NUMROWS]INUMCOLUMNS]: char -price [NUMROWS]: double -int: seatsSold double : totalevenue +TicketManager) +requestTickets(int, int, int): bool +purchaseTickets(int, int, int) : bool +getTotalRevenu0: double + getSeatsSold0: int + getPrice(int) : double + getSeat (int, int) : char + printTickets(int, int, int): void

Explanation / Answer

import java.io.*;
import java.util.*;

class TicketManager{
   final int NUMROWS = 15;
   final int NUMCOLUMNS = 30;
   char[][] seats;
   double[] price;
   int seatsSold;
   double totalRevenue;
   public TicketManager(){
       seats = new char[NUMROWS][NUMCOLUMNS];
       price = new double[NUMROWS];
       seatsSold = 0;
       totalRevenue = 0.0;
   }
   boolean requestTickets(int a,int b,int c){
       for (int i = c-1; i < c+a-1; i++){
           if (seats[b-1][i] == '*')
               return false;
       }
       return true;
   }
   boolean purchaseTickets(int,int,int){
   }
   double getTotalRevenue(){
       return totalRevenue;
   }
   int getSeatsSold(){
       return seatsSold;
   }
   double getPrice(int b){
       return price[b-1];
   }
   char getSeat(int b,int c){
       return seats[b-1][c-1];
   }
   void printTickets(int a,int b,int c){
       for (int i = 0; i < a; i++){
           System.out.println("***********************************************");
           System.out.println("* Gammage Theater *");
           System.out.println("* Row "+b+" Seat "+(c+i)+" *");
           System.out.println("* Price: $ "+getPrice(b)+" *");
           totalRevenue += getPrice(b);
           System.out.println("***********************************************");
           System.out.println(" ");
       }
   }
   void viewSeats(){
       System.out.println(" Seats");
       for (int i = 0; i < 30; i++){
           System.out.print("ROW "+(i+1)+" ");
           for (int j = 0; j < 3; j++)
               System.out.print(seats[i][j]);
           System.out.print(" ");
           int k = 1;
           for (int j = 3; j < 27; j++){
               System.out.print(seats[i][j]);
               if (k % 4 == 0){
                   System.out.print(" ");
                   k = 0;
               }
               k += 1;
           }
           for (int j = 27; j < 30; j++)
               System.out.print(seats[i][j]);
           System.out.println();
       }
       System.out.println(" Legend: * = Sold # = Available ");
   }
}

class main{
   public static void main(String[] args){
       TicketManager tm = new TicketManager();
       try{
           File file = new File("seatAvaiability.txt");
           Scanner input = new Scanner(file);
           int j = 0;
           while (input.hasNextLine()){
               String line = input.nextLine();
               for (int i = 0; i < line.length(); i++)
                   tm.seats[j][i] = line.charAt(i);
               j += 1;
           }
           input.close();
           file = new File("seatPrices.txt");
           input = new Scanner(file);
           for (int i = 0; i < 15; i++)
               tm.price[i] = input.nextDouble();
           input.close();
          
           Scanner sc = new Scanner(System.in);
           while (true){
               System.out.println(" ASU Gammage Theater");
               System.out.println("1. View Available Seats");
               System.out.println("2. Request tickets");
               System.out.println("3. Display Theater Sales Report");
               System.out.println("3. Exit the Program");
               int n = sc.nextInt();
               if (n == 1)
                   tm.viewSeats();
               else if (n == 2){
                   int a,b,c;
                   System.out.print("Select the seats desired (1-30) : ");
                   a = sc.nextInt();
                   System.out.print("Desired row (1-15) : ");
                   b = sc.nextInt();
                   System.out.println("Desired starting seat number in the row (1-30) : ");
                   c = sc.nextInt();
                   boolean result = tm.requestTickets(a,b,c);
                   if (result == true){
                       System.out.println("The seats you have requested are available for purchase");
                       System.out.println("The total purchase price is "+a+" X $"+tm.getPrice(b)+" = $"+(a*tm.getPrice(b)));
                       System.out.println();
                       System.out.print("Do you wish to purchase these tickets(Y/N)? ");
                       char ch = sc.next().charAt(0);
                       if (ch == 'Y' || ch == 'y'){
                           System.out.println("Num Seats : "+a);
                           System.out.println("The price for the requested tickets is : $ "+(a*tm.getPrice(b)));
                           System.out.println("Please input amount paid : $"+(a*tm.getPrice(b)));
                          
                           tm.printTickets(a,b,c);
                       }
                   }
                   else
                       System.out.println("The seats you have requested are not available for purchase");
               }
               else if (n == 3){
                   System.out.println("Gammage Sales Report");
                   System.out.println("-------------------------------");
                   System.out.println("Seats sold : "+tm.getSeatsSold());
                   System.out.println("Seats available : "+(450-tm.getSeatsSold()));
                   System.out.println("Total revenue to date: $"+tm.getTotalRevenue());
               }
               else
                   break;
           }
       }
       catch (Exception ex){
           ex.printStackTrace();
       }
   }
}