Advertisement
mark79

Wedding Seats

Jul 26th, 2019
1,278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 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.  
  7.         char sector = scanner.nextLine().charAt(0);
  8.         int rows = Integer.parseInt(scanner.nextLine());
  9.         int seats = Integer.parseInt(scanner.nextLine());
  10.  
  11.         int factor = 0;
  12.         int counter = 0;
  13.  
  14.         for (char i = 'A'; i <= sector; i++, rows++) {
  15.             for (int j = 1; j <= rows; j++) {
  16.                 factor = (j % 2 == 0) ? 2 : 0;
  17.                 for (char k = 'a'; k < 'a' + seats + factor; k++) {
  18.                     System.out.printf("%c%d%c%n", i, j, k);
  19.                     counter++;
  20.                 }
  21.             }
  22.         }
  23.  
  24.         System.out.printf("%d", counter);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement