Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.3 kB
1
Indexable
Never
package com.company;
import java.util.*;

class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        System.out.println("Enter the number of rows:");
        int row = scanner.nextInt();
        System.out.println("Enter the number of seats in each row.");
        int col = scanner.nextInt();

        System.out.println("Cinema:");
        System.out.print("  ");
        for (int i = 1; i <= col; i++) {
            System.out.print(i + " ");
        }
        System.out.println();

        for (int j = 1; j <= row; j++) {
            System.out.print(j);
            for (int i = 0; i < col; i++){
                System.out.print(" S");
        }
            System.out.println();
    }

        System.out.println("Enter a row number:");
        int rowNumber = scanner.nextInt();
        System.out.println("Enter a seat in that row:");
        int seatInRow = scanner.nextInt();

        if(row * col <= 60){
            System.out.println("Ticket price $10");
        }
        else{
            float halfRows = row / 2;
            if(halfRows >= rowNumber)
                System.out.println("Ticket price $10");
            else
                System.out.println("Ticket price $8");
        }

        System.out.println("Cinema:");
        System.out.print("  ");
        for (int i = 1; i <= col; i++) {
            System.out.print(i + " ");
        }
        System.out.println();
        for(int i = 1; i < rowNumber; i++){
            System.out.print(i);
            for (int j = 0; j < col; j++){
                System.out.print(" S");
            }
            System.out.println();
        }
        System.out.print(rowNumber + " ");
        for (int i = 1; i < seatInRow; i++){
            System.out.print("S ");
        }
        System.out.print("B ");
        for (int i = 0; i < col - seatInRow; i++){
            System.out.print("S ");
        }
        System.out.println();
        rowNumber++;
        for (; rowNumber <= row; rowNumber++) {
            System.out.print(rowNumber + " ");
            for (int i = 0; i < col; i++) {
                System.out.print("S ");
            }
            System.out.println();
        }
        }
    }