Advertisement
Spocoman

06. Wedding Seats

Aug 30th, 2024
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class WeddingSeats {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         char finalSector = scanner.nextLine().charAt(0);
  7.         int rows = Integer.parseInt(scanner.nextLine()),
  8.                 oddSeats = Integer.parseInt(scanner.nextLine()),
  9.                 totalSeats = 0;
  10.  
  11.         for (char i = 'A'; i <= finalSector; i++) {
  12.             for (int k = 1; k <= rows; k++) {
  13.                 int currentSeats = oddSeats;
  14.                 if (k % 2 == 0) {
  15.                     currentSeats += 2;
  16.                 }
  17.                 for (char o = 'a'; o < currentSeats + 97; o++) {
  18.                     System.out.printf("%c%d%c\n", i, k, o);
  19.                     totalSeats++;
  20.                 }
  21.             }
  22.             rows++;
  23.         }
  24.         System.out.println(totalSeats);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement