Member Avatar for Codeslinger

/*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);
  }
}

Okay? That's your assignment, that's your code, what's your problem?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.