yovkovbpfps

Nested Loops Lab Building

Apr 15th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Building {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int floorCount = Integer.parseInt(scanner.nextLine());
  8. int roomsPerFloor = Integer.parseInt(scanner.nextLine());
  9.  
  10. for (int i = floorCount; i > 0; i--) {
  11. for (int j = 0; j < roomsPerFloor; j++) {
  12. if (i == floorCount){
  13. System.out.printf("L%d%d ",i,j);
  14. }else if (i % 2 == 0){
  15. System.out.printf("O%d%d ",i,j);
  16. } else {
  17. System.out.printf("A%d%d " ,i,j);
  18. }
  19. }
  20. System.out.println();
  21. }
  22. }
  23. }
Add Comment
Please, Sign In to add comment