Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package exercises_NestedLoops_9Dec2018;
- import java.util.Scanner;
- public class Task6_WeddingSeats_Nov2018 {
- public static void main(String[] args) {
- @SuppressWarnings("resource")
- Scanner sc = new Scanner(System.in);
- String lastSector = sc.nextLine(); // from 66 (B) to 90 (Z)
- int rowsFirstSector = Integer.parseInt(sc.nextLine()); // from 1 to 100
- int seatsOddRows = Integer.parseInt(sc.nextLine()); // from 1 to 24
- int lastSectorInt = lastSector.charAt(0);
- int countSeats = 0;
- for (int sector = 65; sector <= lastSectorInt; sector++) { // 65 stands for A
- for (int row = 1; row <= rowsFirstSector; row++) {
- int lastSeat = 97 + seatsOddRows;
- if (row % 2 == 0) {
- lastSeat += 2;
- }
- for (int seats = 97; seats < lastSeat; seats++) {
- System.out.printf("%c%d%c%n", sector, row, seats);
- countSeats++;
- }
- }
- rowsFirstSector++;
- }
- System.out.println(countSeats);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement