Advertisement
desislava_topuzakova

06. Building

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