Advertisement
Guest User

Pensionato.java

a guest
Mar 21st, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. package oop;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Pensionato {
  6.  
  7. public static void main(String[] args) {
  8. Scanner sc = new Scanner(System.in);
  9.  
  10. String[] rooms = new String[10];
  11.  
  12. System.out.print("How many rooms will be rented? ");
  13. int rented = sc.nextInt();
  14. if (rented > 10) {
  15. System.out.println("The rooms avaliable's maximum 10, try again.");
  16. System.out.print("How many rooms will be rented? ");
  17. rented = sc.nextInt();
  18. }
  19.  
  20. sc.nextLine();
  21. System.out.println();
  22.  
  23. int cont = 0;
  24. for(int i=1; i <= rented; i++) {
  25. System.out.println("Rent #"+ i +":");
  26.  
  27. System.out.print("Name: ");
  28. String name = sc.nextLine();
  29.  
  30. System.out.print("Email: ");
  31. String email = sc.nextLine();
  32.  
  33. System.out.print("Room: ");
  34. int room = sc.nextInt();
  35. sc.nextLine();
  36. cont++;
  37. rooms[cont] = room+
  38. ": "+name+
  39. ", "+email;
  40. System.out.println();
  41. }
  42.  
  43. System.out.println("Busy rooms:");
  44. while (cont > 0) {
  45. System.out.println(rooms[cont]);
  46. cont--;
  47. }
  48. sc.close();
  49. }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement