Advertisement
SensaBG

06. Wedding Seats

Aug 4th, 2024
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 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 amountLinesSectorOne = Integer.parseInt(scanner.nextLine());
  9. int oddLines = Integer.parseInt(scanner.nextLine());
  10.  
  11. int evenLines = oddLines + 2;
  12. int totalSeats = 0;
  13.  
  14. for (char sector = 'A'; sector <= lastSector; sector++) {
  15. for (int line = 1; line <= amountLinesSectorOne; line++) {
  16. int seatsOnCurrentLine = (line % 2 == 1) ? oddLines : evenLines;
  17.  
  18. for (char seat = 'a'; seat < 'a' + seatsOnCurrentLine; seat++) {
  19. System.out.printf("%c%d%c%n", sector, line, seat);
  20. totalSeats++;
  21. }
  22. }
  23. amountLinesSectorOne++;
  24. }
  25.  
  26. System.out.println(totalSeats);
  27. }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement