Advertisement
veronikaaa86

06. Building

Oct 15th, 2022
973
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. package nestedLoops;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P06Building {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int floorsCount = Integer.parseInt(scanner.nextLine());
  10.         int roomsCount = Integer.parseInt(scanner.nextLine());
  11.  
  12.         for (int floor = floorsCount; floor >= 1; floor--) {
  13.             for (int room = 0; room < roomsCount; room++) {
  14.                 if (floor == floorsCount) {
  15.                     System.out.printf("L%d%d ", floor, room);
  16.                 } else if (floor % 2 == 0) {
  17.                     System.out.printf("O%d%d ", floor, room);
  18.                 } else {
  19.                     System.out.printf("A%d%d ", floor, room);
  20.                 }
  21.             }
  22.             System.out.println();
  23.         }
  24.     }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement