Advertisement
Deiancom

Wedding Seats ver.1.6

Sep 17th, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. package NestedLoops;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class WeddingSeats {
  6.     public static void main(String[] args) {
  7.         Scanner sc = new Scanner(System.in);
  8.         char lastSector = sc.nextLine().charAt(0);
  9.         int rowsFirst = Integer.parseInt(sc.nextLine()) - 1;
  10.         int places = Integer.parseInt(sc.nextLine());
  11.         int count = 0;
  12.  
  13.         for (int a = 65; a <= lastSector; a++) {
  14.             rowsFirst++;
  15.             for (int b = 1; b <= rowsFirst; b++) {
  16.                 if (b % 2 == 0) {
  17.                     int newPlaces = places + 97 + 2;
  18.                     for (int c = 97; c < newPlaces; c++) {
  19.                         System.out.printf("%c%d%c%n", a, b, c);
  20.                         count++;
  21.                     }
  22.                 } else {
  23.                     int newPlaces = places + 97;
  24.                     for (int c = 97; c < newPlaces; c++) {
  25.                         System.out.printf("%c%d%c%n", a, b, c);
  26.                         count++;
  27.                     }
  28.                 }
  29.             }
  30.         }
  31.         System.out.println(count);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement