SvetlanPetrova

Building SoftUni

May 22nd, 2021
1,034
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class demo2 {
  5.     public static void main(String[] args){
  6.         Scanner scanner = new Scanner(System.in);
  7.         //1. етажите от последния към първия
  8.         //2. за всеки един етаж -> стаите от 0 до последната
  9.         int floors = Integer.parseInt(scanner.nextLine());
  10.         int rooms = Integer.parseInt(scanner.nextLine());
  11.         for (int floor = floors; floor >= 1 ; floor--) {
  12.             for (int room = 0; room < rooms; room++) {
  13.                 //{буква за тип на стаята}{етаж}{номер на стаята}
  14.                 if(floor == floors) {
  15.                     System.out.printf("L%d%d ",floor, room);
  16.                 } else if (floor % 2 == 1) {
  17.                     System.out.printf("A%d%d ",floor, room);
  18.                 } else if (floor % 2 == 0) {
  19.                     System.out.printf("O%d%d ",floor, room);
  20.                 }
  21.             }
  22.             System.out.println();
  23.  
  24.         }
  25.  
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment