import java.io.*; public class Room_mgmt_2 { public static void main(String[] args) throws IOEception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); boolean status = true, stat = true; int numoffloor = 0; int menu = 0; int fn = 0; System.out.println("================================"); System.out.println("\thotel management"); System.out.println("================================"); System.out.println("Number of floors = "); numoffloor = Integer.parseInt(in.readLine()); System.out.println(); int[] numofroom = new int[numoffloor]; String[][] roomname = new String[numoffloor][]; String[][] guestname = new String[numoffloor][]; int[][] numofparty = new int[numoffloor][]; int[][] charge = new int[numoffloor][]; int[][] days = new int[numoffloor][]; for(int i=0;i<numoffloor;i++) { System.out.print("Number of rooms of floor " + (i+1) + "="); numofroom[i] = Integer.parseInt(in.readLine()); System.out.println(); roomname[i] = new String[numofroom[i]]; guestname[i] = new String[numofroom[i]]; numofparty[i] = new int[numofroom[i]]; charge[i] = new int[numofroom[i]]; days[i] = new int[numofroom[i]]; System.out.println("Basic Data floor #" + (i+1) + ":"); for(int j=0;j<numofroom[i];j++) { System.out.println(" Basic Data for Room #" + (j+1) + " : "); System.out.println(" Room name = "); roomname[i][j] = in.readLine(); System.out.print(" Charge for 1 day = "); charge[i][j] = Intger.parseint(in.readLine()); } } do { System.out.println(" 1 : Check in / 2 : Check out / 3 : Room Information / 0 : Exit"); System.out.print("Type Menu (0~3) = "); menu = Integer.parseInt(in.readLine()); System.out.println(); stat = true; switch (menu) { case 0: status = false; break; case 1: do { stat = false; System.out.print(" Check in Floor = "); fn = Integer.parseInt(in.readLine()); if(fn <= 0 || numofloor < fn) stat=true; } while (stat); fn--; stat=true; System.out.println(); System.out.println("\tFloor = " + (fn + 1)); System.out.println("\t==========\t ==========\t ==========\t =========="); System.out.println("\tRoom #\t Room Name\t Charge/day\t Guest\t Num of party"); System.out.println("\t==========\t ==========\t ==========\t =========="); for(int i=0;i<numofroom[fn];i++) System.out.println("\t" + (i+1) + "\t " + roomname[fn][i] + "\t " + charge[fn][i] + "/day\t " + guestname[fn][i] + "\t " + numofparty[fn][i]); System.out.println("\t==========\t ==========\t ==========\t =========="); do { System.out.print(" Check in Room Number ( 0 = cancel ) = "); int rn = Integer.parseInt(in.readLine()); if(rn == ) break; --rn; if(0<=rn && rn < numofroom[fn] && guestname[fn][fn] == null) { stat = false; System.out.print(" Guest name = "); guestname[fn][fn] = in.readLine(); System.out.print(" Number of party = "); numofparty[fn][fn] = Integer.parseInt(in.readLine()); System.out.print(" Number of day = "); days[fn][rn] = Integer.parseInt(in.readLine()); } } while (stat); break; case 2: do { stat = false; System.out.print(" Check out Floor = "); fn = Integer.parseInt(in.readLine()); if(fn <= 0 || numofloor < fn) stat=true; } while(stat); fn--; stat = true; System.out.println(); System.out.println("\tFloor = " + (fn + 1)); System.out.println("\t==========\t ==========\t ==========\t =====\t==========\t =====\t ============"); System.out.println("\tRoom #\t Room Name\t Charge/day\t Guest\t Num of party"); System.out.println("\t==========\t ==========\t ==========\t =====\t==========\t =====\t ============"); for(int i=0; i<numofroom[fn]; i++) System.out.println("\t" + (i+1) + "\t " + roomname[fn][i] + "\t " + charge[fn][i] + "/day\t " + guestname[fn][i] + "\t " + numofparty[fn][i]); System.out.println("\t==========\t ==========\t ==========\t =====\t==========\t =====\t ============"); do { System.out.print(" Check out Room Number ( 0 = cancel ) = "); int rn = Integer.parseInt(in.readLine()); if(rn == ) break; --rn; if( 0 <= rn && rn < numofroom[fn] && guestname[fn][fn] != null) { stat = false; System.out.println("\t==========\t ==========\t ==========\t =====\t==========\t =====\t ============"); System.out.println("\t" + (rn+1) + "\t " + roomname[fn][fn] + "\t " + charge[fn][rn] + "/day"); System.out.println("\t\t " + guestname[fn][rn] + " (" + numofparty[fn][rn] + ")\t \" + days[fn][rn] * charge[fn][rn] + "/" + days[fn][rn] + " days"); System.out.println("\t==========\t ==========\t ==========\t =====\t==========\t =====\t ============"); guestname[fn][rn] = null; numofparty[fn[prn] = 0; days[fn][rn] = 0; } } while (stat); break; case 3: for (fn = 0; fn < numoffloor; fn++) { // System.out.println("\t==========\t ==========\t ==========\t =====\t==========\t =====\t ============"); System.out.println(); System.out.println("\tFloor = " + (fn + 1)); System.out.println("\t==========\t ==========\t ==========\t =====\t==========\t =====\t ============"); System.out.println("\tRoom #\t Room Name\t Charge/day\t Guest\t Num of party"); System.out.println("\t==========\t ==========\t ==========\t =====\t==========\t =====\t ============"); for (int i = 0; i < numofroom[fn]; i++) System.out.println("\t" + (i+1) + "\t "+ roomname[fn][i] + "\t " + charge[fn][i] + "/day\t " + guestname[fn][i] + "\t " + numofparty[fn][i]); System.out.println("\t==========\t ==========\t ==========\t =====\t==========\t =====\t ============"); } break; default: System.out.println("illegal menu1"); } } while (status); System.out.println("Good Luck! Bye"); } } |
'내 첫사랑! 컴퓨터 프로그래밍 > 자바는 나의 친구' 카테고리의 다른 글
자바 개요 (0) | 2020.05.12 |
---|---|
자바,이클립스 설치 및 설정 (0) | 2019.12.13 |
[Java] 반, 전교 성적처리 예제 소스 (0) | 2016.12.08 |
자바에서 while(true) (0) | 2016.12.07 |
System.in.read() 함수, System.in.readLine() 함수 [출처] System.in.read() 함수, System.in.readLine() 함수 (0) | 2016.12.05 |