Untitled

 avatar
unknown
plain_text
2 years ago
2.0 kB
6
Indexable
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("Enter the number of rows:");
        int rows = scanner.nextInt();
        System.out.println("Enter the number of seats in each row:");
        int seats = scanner.nextInt();
        int allSeats = rows * seats;
        int ticketsUpper = 10;
        int ticketsLower = 8;
        
        System.out.println("Cinema:");
        for (int i = 0; i < (rows + 1); i++) {
            for (int j = 0; j < (seats + 1); j++) {
                if (i == 0 && j == 0) {
                    System.out.print("  ");
                } else if (i == 0 && j > 0) {
                    System.out.print(j + " ");
                } else if (i > 0) {
                    if (j == 0) {
                        System.out.print(i + " ");
                    } else {
                        System.out.print("S ");
                    } 
                }
            }
            
            System.out.println();
        } 
        
        System.out.println("Enter a row number:");
        int rowNumber = scanner.nextInt();
        System.out.println("Enter a seat number in that row:");
        int seatNumber = scanner.nextInt();
        
        if (allSeats >= 60) {
            if (rowNumber < (rows / 2)) {
                System.out.printf("Ticket price: $%d\n", ticketsUpper);
            } else {
               System.out.printf("Ticket price: $%d\n", ticketsLower); 
            }
        } else {
            System.out.printf("Ticket price: $%d\n", ticketsUpper);
        }
        
        String[][] cinema = new String[rows][seats];
        System.out.println("Cinema:");
        System.out.println("  1 2 3 4 5 6 7 8 9");
        for (int i = 0; i <= rows; i++) {
            for (int j = 0; j <= seats; j++) {
                if (j == 0) {
                    cinema[i][j] = j + " ";
                }
            }
        }
    }
}    
Editor is loading...