Package com;
Import Java.util.Scanner;
/**
* Created by Frankie on 2016/3/28.
*/
public class Hotelsys {
public static int h = 5;
public static int w = 15;
public static string[][] rooms = new STRING[H][W];
public static void Main (string[] args) {
Scanner sc = new Scanner (system.in);
while (true) {
System.out.print ("Please enter the operation (1, open room, 2, check out, 3, view, 0, System exit):");
int k = Sc.nextint ();
Switch (k) {
Case 1:
System.out.print ("Please enter room Number:");
int rn = Sc.nextint ();
System.out.print ("Please enter Name:");
String nn = Sc.next ();
In (RN,NN);
Break
Case 2:
System.out.print ("Please enter room Number:");
int on = Sc.nextint ();
Out (on);
Break
Case 3:
Search ();
Break
Default
SYSTEM.OUT.PRINTLN ("System exit");
System.exit (0);
Break
}
}
}
public static void in (int roomnum,string name) {
int r = roomnum/100-1;
int c = roomnum%100-1;
System.out.println (R);
System.out.println (c);
if (r<0 | | r>=h | | c<0 | | c>=w) {
System.out.println ("The room number does not exist, failed to open the room");
}else if (rooms[r][c]==null) {
System.out.println ("Congratulations, open room success, please remember your room number:" +roomnum);
Rooms[r][c]=name;
}else{
System.out.println ("The room number of someone, the failure to open the room");
}
}
public static void out (int roomnum) {
int r = roomnum/100-1;
int c = roomnum%100-1;
if (r<0 | | r>=h | | c<0 | | c>=w) {
System.out.println ("The room number does not exist, check-out failed");
}else if (rooms[r][c]==null) {
System.out.println ("No one in this room, check out failed");
}else{
ROOMS[R][C] = null;
System.out.println ("Exit success, Room Number:" +roomnum+ ", welcome to the next visit.");
}
}
public static void Search () {
for (int i = 0; i < rooms.length; i++) {
for (int j = 0; J <rooms[i].length; J + +) {
String info = rooms[i][j]==null? "": "Someone";
int nn = (i+1) *100+j+1;
System.out.print ("\ t" + "[" +i+ "] [" +j+ "]=" +info ");
System.out.print ("\ t room Number:" +nn+ "=" +info);
System.err.print ("\ t" + "[" +i+ "] [" +j+ "]=" +rooms[i][j]);
}
System.out.println ();
}
}
}
Hotel Open room System, Java written Oh, not difficult! Let's not laugh at my stupidity.