Advertisement
damesova

Wedding Seats - Java

Dec 18th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. package Exam3Nov18;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class WeddingSeats {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. char maxSector = scanner.nextLine().charAt(0);
  10. int rowsFirstSec = Integer.parseInt(scanner.nextLine());
  11. int seatsOddRows = Integer.parseInt(scanner.nextLine());
  12. int count = 0;
  13.  
  14. for (char sec = 'A'; sec <= maxSector; sec++) {
  15. for (int row = 1; row <= rowsFirstSec; row++) {
  16. if (row % 2 == 1) {
  17. for (int seat = 1; seat <= seatsOddRows; seat++) {
  18. System.out.printf("%c%d%c%n", sec, row, (char) (seat + 96));
  19. count++;
  20. }
  21. } else {
  22. for (int seat = 1; seat <= seatsOddRows + 2; seat++) {
  23. System.out.printf("%c%d%c%n", sec, row, (char) (seat + 96));
  24. count++;
  25. }
  26. }
  27. }
  28. rowsFirstSec++;
  29. }
  30. System.out.println(count);
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement