veronikaaa86

06. Building

Apr 10th, 2021
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 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. String letter = "";
  15. if (floor == countFloors){
  16. letter = "L";
  17. //System.out.printf("L%d%d ", floor, room);
  18. }else if (floor % 2 != 0) {
  19. letter = "A";
  20. //System.out.printf("A%d%d ", floor, room);
  21. } else {
  22. letter = "O";
  23. //System.out.printf("O%d%d ", floor, room);
  24. }
  25.  
  26. System.out.printf("%s%d%d ", letter, floor, room);
  27. }
  28. System.out.println();
  29. }
  30. }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment