Advertisement
desislava_topuzakova

Untitled

Oct 19th, 2022
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 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 lastSector = scanner.nextLine().charAt(0);
  8. int rowCount = Integer.parseInt(scanner.nextLine());
  9. int seatCount = Integer.parseInt(scanner.nextLine());
  10.  
  11. int counter = 0;
  12. for (char sector = 'A'; sector <= lastSector; sector++, rowCount++) {
  13. for (int row = 1; row <= rowCount; row++) {
  14. int seatInRow = seatCount;
  15. if (row % 2 == 0) {
  16. seatInRow = seatCount + 2;
  17. }
  18. for (char seat = 'a'; seat < 'a' + seatInRow; seat++) {
  19. System.out.printf("%c%d%c%n", sector, row, seat);
  20. counter++;
  21. }
  22. }
  23. }
  24. System.out.print(counter);
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement