Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Exam3Nov18;
- import java.util.Scanner;
- public class WeddingSeats {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- char maxSector = scanner.nextLine().charAt(0);
- int rowsFirstSec = Integer.parseInt(scanner.nextLine());
- int seatsOddRows = Integer.parseInt(scanner.nextLine());
- int count = 0;
- for (char sec = 'A'; sec <= maxSector; sec++) {
- for (int row = 1; row <= rowsFirstSec; row++) {
- if (row % 2 == 1) {
- for (int seat = 1; seat <= seatsOddRows; seat++) {
- System.out.printf("%c%d%c%n", sec, row, (char) (seat + 96));
- count++;
- }
- } else {
- for (int seat = 1; seat <= seatsOddRows + 2; seat++) {
- System.out.printf("%c%d%c%n", sec, row, (char) (seat + 96));
- count++;
- }
- }
- }
- rowsFirstSec++;
- }
- System.out.println(count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement