Advertisement
Guest User

WeddingSeats

a guest
Dec 18th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. package exercises_NestedLoops_9Dec2018;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Task6_WeddingSeats_Nov2018 {
  6. public static void main(String[] args) {
  7. @SuppressWarnings("resource")
  8.  
  9. Scanner sc = new Scanner(System.in);
  10. String lastSector = sc.nextLine(); // from 66 (B) to 90 (Z)
  11. int rowsFirstSector = Integer.parseInt(sc.nextLine()); // from 1 to 100
  12. int seatsOddRows = Integer.parseInt(sc.nextLine()); // from 1 to 24
  13.  
  14. int lastSectorInt = lastSector.charAt(0);
  15. int countSeats = 0;
  16.  
  17. for (int sector = 65; sector <= lastSectorInt; sector++) { // 65 stands for A
  18. for (int row = 1; row <= rowsFirstSector; row++) {
  19. int lastSeat = 97 + seatsOddRows;
  20. if (row % 2 == 0) {
  21. lastSeat += 2;
  22. }
  23. for (int seats = 97; seats < lastSeat; seats++) {
  24. System.out.printf("%c%d%c%n", sector, row, seats);
  25. countSeats++;
  26. }
  27. }
  28. rowsFirstSector++;
  29. }
  30. System.out.println(countSeats);
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement