Advertisement
veronikaaa86

06. Building

Nov 6th, 2021
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 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 countFloors = Integer.parseInt(scanner.nextLine());
  10. int countRooms = Integer.parseInt(scanner.nextLine());
  11.  
  12. for (int floor = countFloors; floor >= 1; floor--) {
  13. for (int room = 0; room < countRooms; room++) {
  14.  
  15. String typeRoom = "";
  16. if (floor == countFloors) {
  17. typeRoom = "L";
  18. } else if (floor % 2 != 0) {
  19. typeRoom = "A";
  20. } else {
  21. typeRoom = "O";
  22. }
  23. System.out.printf("%s%d%d ", typeRoom, floor, room);
  24. }
  25. System.out.println();
  26. }
  27. }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement