这是1个方法代码。
import java.io.*;
public class Main {
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
double [] NightRate = {0, 500, 800, 1240, 1500};//Night Rate
double GuestRate = 100; // Guess Rate
boolean First = true, Second = true, Third = true, Fourth = true; // Loop
int Standard = 4, Double = 4, Matrimonial = 4, Triple = 4;//Bed Types
int SwitchOne, SwitchTwo = 0;
String SwitchThree, SwitchFour, SwitchFive, SwitchSix;// For Switches
String Anykey;// For The Condition Of Every Room
String YesNo;// Yes Or No
String SecretPassword = "151";//Secret Password
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());
SwitchOne = 0;
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 (SwitchOne == 1){ //Standard - SwitchOne
if ((Standard < 5) && (Standard > 1)){
System.out.println("\n \t" + (Standard - 1) + " Standard Room Available");
System.out.print("|---------------------------------------------------------------------|");
System.out.print("\nOur Standard Room (1 Person) is ");
System.out.print("exquisitely prepared bed linen,"
+ "\nan interior bathed in warm light, "
+ "\nand a relaxing bathtub in a sparkling clean bathroom. "
+ "\nIn this atmosphere, guests are sure to feel the detailed attentiveness "
+ "\nthat is the foundation of M.Y service.\n");
System.out.print("|---------------------------------------------------------------------|\n\n");
}else if ((Standard - 1) == 0){
System.out.print("\n--------------------------------------------------------------------|");
System.out.print ("\nRoom Not Available Right Now. \nPlease Try Again Next Time.");
System.out.print("\n--------------------------------------------------------------------|\n\n");
continue;
}
}else if (SwitchOne == 2){ //Double - SwitchOne
if ((Double < 5) && (Double > 1)){
System.out.println("\n \t" + (Double - 1) + " Double Room Available");
System.out.print("|---------------------------------------------------------------------|");
System.out.print("\nOur Double Room (2 Person) is"
+ " most suitable for couples and the size"
+ " \nenables you to relax and feel at home. "
+ "\nAll rooms are also fitted with a desk, a closet and a washlet.");
System.out.print("\n|---------------------------------------------------------------------|\n\n");
}else if ((Double - 1) == 0){
System.out.print("\n--------------------------------------------------------------------|");
System.out.print ("\nRoom Not Available Right Now. \nPlease Try Again Next Time.");
System.out.print("\n--------------------------------------------------------------------|\n\n");
break;
}
}else if (SwitchOne == 3){//Matrimonial - SwitchOne
if ((Matrimonial < 5) && (Matrimonial > 1)){
System.out.println("\n" + "\t" + (Matrimonial - 1) + " Matrimonial Room Available");
System.out.print("|---------------------------------------------------------------------|");
System.out.print("\nOur Matrimonial (2 Person) is ");
System.out.print("one of our best features, "
+ "\nwhere you can share with your beloved the unforgettable"
+ "\nexperience offered "
+ "by staying in our hotel.\n");
System.out.print("|---------------------------------------------------------------------|\n\n");
}else if ((Matrimonial - 1) == 0){
System.out.print("\n--------------------------------------------------------------------|");
System.out.print ("\nRoom Not Available Right Now. \nPlease Try Again Next Time.");
System.out.print("\n--------------------------------------------------------------------|\n\n");
continue;
}
}else if (SwitchOne == 4){ //Triple - SwitchOne
if ((Triple < 5) && (Triple > 1)){
System.out.println("\n \t" + (Triple - 1) + " Triple Room Available");
System.out.print("|---------------------------------------------------------------------|");
System.out.print("\nOur Triple Room (3 Person) is ");
System.out.print("deal for families and"
+ "\nlarge enough to accommodate 3 people. "
+ "\nThey also feature full private bath");
System.out.print("\n|---------------------------------------------------------------------|\n\n");
}else if ((Triple - 1) == 0){
System.out.print("\n--------------------------------------------------------------------|");
System.out.print ("\nRoom Not Available Right Now. \nPlease Try Again Next Time.");
System.out.print("\n--------------------------------------------------------------------|\n\n");
continue;
}
}else if (SwitchOne == 5){
System.exit(0);
}else{// Default - SwitchOne
System.out.print("\n>>>> Invalid Keyword! <<<<\n");
continue;
}//End of Switch for SwitchOne - First Switch
if (SwitchOne == 1){
do{//Start of Loop - Third Loop
Second = true;
System.out.print("\n1. Book.");
System.out.print("\n2. Back.");
System.out.print("\n\nPlease Select: ");
SwitchTwo = Integer.parseInt(br.readLine());
if (SwitchOne == 1){
Standard--;
}
if (SwitchOne == 2){
Double--;
}
if (SwitchOne == 3){
Matrimonial--;
}
if (SwitchOne == 4){
Triple--;
}
if (SwitchTwo == 1){
System.out.print("\nHave A Nice Day!\n");
Second = false;
break;
}else if (SwitchTwo == 2){
break;
}else{
System.out.print("Invalid Keyword!");
continue;
}
}while (Third);//End Of Loop - Third
}
if (SwitchOne == 2){
do{//Start of Loop - Third Loop
Second = true;
System.out.print("\n1. Book.");
System.out.print("\n2. Back.");
System.out.print("\n\nPlease Select: ");
SwitchTwo = Integer.parseInt(br.readLine());
if (SwitchTwo == 1){
System.out.print("\nHave A Nice Day!\n");
Second = false;
break;
}else if (SwitchTwo == 2){
break;
}else{
System.out.print("Invalid Keyword!");
continue;
}
}while (Third);//End Of Loop - Third
}
if (SwitchOne == 3){
do{//Start of Loop - Third Loop
Second = true;
System.out.print("\n1. Book.");
System.out.print("\n2. Back.");
System.out.print("\n\nPlease Select: ");
SwitchTwo = Integer.parseInt(br.readLine());
if (SwitchTwo == 1){
System.out.print("\nHave A Nice Day!\n");
Second = false;
break;
}else if (SwitchTwo == 2){
break;
}else{
System.out.print("Invalid Keyword!");
continue;
}
}while (Third);//End Of Loop - Third
}
if (SwitchOne == 4){
do{//Start of Loop - Third Loop
Second = true;
System.out.print("\n1. Book.");
System.out.print("\n2. Back.");
System.out.print("\n\nPlease Select: ");
SwitchTwo = Integer.parseInt(br.readLine());
if (SwitchTwo == 1){
System.out.print("\nHave A Nice Day!\n");
Second = false;
break;
}else if (SwitchTwo == 2){
break;
}else{
System.out.print("Invalid Keyword!");
continue;
}
}while (Third);//End Of Loop - Third
}
}while(Second);// End Of Second Loop - Main Menu
}// End For Records
System.out.print("\n\nList Of Customers:");
for (int 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]);
}
}while (First);//End Of First Loop - Customer's Info
}//IO
}//Body
事情是,当它显示客户列表时,它具有相同的住宿。
“System.out.println(”\ nAccommodations:| ---------------&gt;“+ Accommodation [SwitchOne]);”
必须由客户选择显示。
并且必须在完成记录后打印。
请帮助我!
答案 0 :(得分:0)
错误是自动解决的,您必须初始化变量SwitchOne。
int SwitchOne=0, SwitchTwo;
您还有一个错误:
if (SwitchOne == SwitchOne) {//line 203