這是1種方法。如何顯示將取決於用戶想要的數組?
public static void main(String[] Ropher)throws IOException{
BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
String[] Accommodation = {"", "Standard Room", "Double Room", "Matrimonial Room", "Triple Room"}; // Accommodation
int SwitchOne, SwitchTwo;
int Option;//Options
/*-----------------------------------------------------------------
* Costumer's Information
-----------------------------------------------------------------*/
do{//Start Of First Loop - Customer's Info
System.out.print("\nEnter Number Of Records : ");
int Records = Integer.parseInt(br.readLine());
String [][] Fullname = new String [Records][100];
int [] Night = new int[100];
int [] Guest = new int[100];
int[] Confirm = new int [100];
for (int x = 0; x < Records; x++){// Start For Records
System.out.print("\nConfimation Number: ");
Confirm[x] = Integer.parseInt(br.readLine());
System.out.print("\nFirst Name: ");
Fullname[x][0] = br.readLine();
System.out.print("Last Name: ");
Fullname[x][1] = br.readLine();
System.out.print("Guest: ");
Guest[x] = Integer.parseInt(br.readLine());
System.out.print("Night: ");
Night[x] = Integer.parseInt(br.readLine());
System.out.println();
do{// Start Of Second - Main Menu
System.out.print("\n ||Main Menu||\n\n");
System.out.print("|=====================================================================|");
System.out.print("\n ************************ Bed Types ************************\n");
System.out.print("|=====================================================================|\n\n");
System.out.print("1. Standard..............................................P500.00\n");
System.out.print("2. Double................................................P800.00\n");
System.out.print("3. Matrimonial...........................................P1,240.00\n");
System.out.print("4. Triple................................................P1,500.00 \n");
System.out.print("5. Exit\n");
System.out.println("\n (WIfi, air conditioned room, LED TV, FREE BREAKFAST)");
System.out.println("\t *Except Standard rooms and Double rooms");
System.out.print("\n\nPlease Select Room Type: ");
SwitchOne = Integer.parseInt(br.readLine());
//Start of Switch for SwitchOne - First Switch
if ((x + 1 - Records) == 0){
System.out.print("\n\nList Of Customers:");
for (x = 0; x < Records; x++){
System.out.print("\n|---------------------------------------------------------------------|\n");
System.out.print("\n\nConfirmation Number: |---------------> " + Confirm[x]);
System.out.print("\nGuest Name: |---------------> " + Fullname [x][0] + " " + Fullname [x][1]);
System.out.print("\nNumber Of Guest: |---------------> " + Guest [x]);
System.out.print("\nNumber Of Nights: |---------------> " + Night[x]);
這只是一個選項,我只是不知道什麼價值放在住宿。
System.out.println(「\ nAccommodations:| --------------->」+ Accommodation [SwitchOne]);
}
}else{
continue;
}
}// End For Records
}while (First);//End Of First Loop - Customer's Info
}//IO
}//Body
我的計劃是所有關於酒店信息和計費系統。
如果有2位顧客想要辦理登機手續並且他們選擇不同的房間,並且當我檢查客戶名單時,他們房間的輸出是相同的。
而且我知道,這個問題是
System.out.println("\nAccommodations: |---------------> " + Accommodation[SwitchOne]);
我會做什麼,以固定的呢?
請幫我解決這個問題。
請將其降低到相關的代碼部分 –
這夠了嗎? @Parker_Halo – Geoddie
歡迎來到SO。如果你有以下情況,人們會更願意閱讀: - 縮進代碼。 - 遵循Java約定,並使變量以小寫字母開頭。 - 做一些更努力的解釋,不需要人們努力去解釋你的意思(_「叫一個陣列」_?_「爲住房提供什麼價值」_以便...? _「問題是如果記錄是2客戶是2 ...」_那整個句子是什麼意思?)。 沒有關係,只要有足夠的努力,上述所有內容都可以被理解。減少幫助你所需的努力是你的工作。 – SantiBailors