Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. package com.company.More;
  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.         String sector = scanner.nextLine();
  10.         int firstSectorSeats = Integer.parseInt(scanner.nextLine()) - 1;
  11.         int oddSeats = Integer.parseInt(scanner.nextLine());
  12.         int oddSeatsReset = 0;
  13.  
  14.         char sectorChar = sector.charAt(0);
  15.  
  16.         int counter = 0;
  17.  
  18.         for (char i = 'A' ; i <= sectorChar ; i++) {
  19.             firstSectorSeats++;
  20.             for (int j = 1; j <= firstSectorSeats ; j++) {
  21.                 if (j % 2 == 0){
  22.                     oddSeatsReset = (oddSeats * 2);
  23.                 } else {
  24.                     oddSeatsReset = oddSeats;
  25.                 }
  26.                 for (char k = 'a'; k < oddSeatsReset + 'a' ; k++) {
  27.  
  28.                     System.out.printf("%c%d%c%n",i,j,k);
  29.  
  30.                     counter++;
  31.                 }
  32.             }
  33.  
  34.         }
  35.  
  36.         System.out.println(counter);
  37.  
  38.  
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement