0

/*THIS PROGRAM PROMPTS THE USE TO INPUT ROOM NUMBERS AND THE FIRST INPUTTED NUMBER WILL BE "OCCUPIED" , AND IF THE ROOM NUMBER(IN THE FIRST INPUT) IS INPUTTED AGAIN AT THE SECOND INPUT IT WILL SAY THAT IT IS "NOT AVAILABLE" . . */

//Here is my code :

import java.io.*;

public class Room {
    public static void main(String[] args)throws IOException {
        int[] arr = new int[5];
	int input, i = 0;
		
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
	do {
	    System.out.print("Enter Room Number: ");
	    input = Integer.parseInt(in.readLine());
	    arr[i] = input;
			
	    if(arr[i] == input) {
	        System.out.println("Reserved");
	    }
			
	    else {
	        System.out.print("Occupied, Not Available");
	    }		
	}while(input != -1);
  }
}
3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by apines
0

Just posting your code is not enough - do you get an exception thrown? compiler errors? unexpected output? Help us to help you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.