Hotel Open room System, Java written Oh, not difficult! Let's not laugh at my stupidity.

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.