Advertisement
veronikaaa86

06. Building

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