This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Aug 25th, 2013  |  syntax: None  |  size: 1.62 KB  |  views: 73  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.util.Arrays;
  2. import java.util.Scanner;
  3. public class 9
  4. {
  5.         public static void main(String[] args)
  6.         {
  7.                 Scanner stdIn = new Scanner(System.in);
  8.                 String[] roomList = new String[7]; //hotel room numbers
  9.                 int filledElements = 0; // number of hotel rooms
  10.                 String roomNum; //entered hotel room number
  11.                 System.out.print("Enter hotel room number (or q to quit): ");
  12.                 roomNum = stdIn.nextLine();
  13.                 while (!roomNum.equalsIgnoreCase("q") &&
  14.                         filledElements < roomList.length)
  15.                  {
  16.                          if (roomNum.length() < 1 || roomNum.length() > 6)
  17.                          {
  18.                                  System.out.println("Invalid entry." +  "Must enter between 1 and 16 characters.");
  19.                  }
  20.                 else
  21.                 {
  22.                         roomList[filledElements] = roomNum;
  23.                         filledElements++;
  24.                 }
  25.                 System.out.print("Enter hotel room number (or q to quit): ");
  26.                 roomNum = stdIn.nextLine();
  27.         } //end while
  28.         System.out.println("\n The Occupied rooms:");
  29.         for (int i=0; i<filledElements; i++)
  30.         {
  31.                 System.out.println((i + 1) + ". " + roomList[i]);
  32.          }  //end for
  33.         public static void main (int[] args)
  34.         {
  35.      Scanner stdIn = new Scanner(System.in);
  36.      int [] rooms= {1,56,19,160,34,18};
  37.      OccupiedRoom = new room(ids,ids.length);
  38.      int id;  //room being searched for
  39.      int index;  //Room number sought or -1 if not found
  40.  
  41.      System.out.print("Please enter a hotel room number, -1 to quit: ") ;
  42.      id = stdIn.nextInt();
  43.      index = room.findroom(id) ;
  44.      if (index >= 0)
  45.      {
  46.        System.out.println("Room is occupied " + index) ;
  47.      }
  48.      else
  49.      {
  50.        System.out.println("room is free");
  51.         }//end main
  52. } //end class 9
clone this paste RAW Paste Data