Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package oop;
- import java.util.Scanner;
- public class Pensionato {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- String[] rooms = new String[10];
- System.out.print("How many rooms will be rented? ");
- int rented = sc.nextInt();
- if (rented > 10) {
- System.out.println("The rooms avaliable's maximum 10, try again.");
- System.out.print("How many rooms will be rented? ");
- rented = sc.nextInt();
- }
- sc.nextLine();
- System.out.println();
- int cont = 0;
- for(int i=1; i <= rented; i++) {
- System.out.println("Rent #"+ i +":");
- System.out.print("Name: ");
- String name = sc.nextLine();
- System.out.print("Email: ");
- String email = sc.nextLine();
- System.out.print("Room: ");
- int room = sc.nextInt();
- sc.nextLine();
- cont++;
- rooms[cont] = room+
- ": "+name+
- ", "+email;
- System.out.println();
- }
- System.out.println("Busy rooms:");
- while (cont > 0) {
- System.out.println(rooms[cont]);
- cont--;
- }
- sc.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement