desislava_topuzakova

Problems 01. Clock 02. Multiplication Table 03. Combinations 04. Sum of Two Numbers 05. Travelling

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