사용자가 주 메뉴로 돌아 오는 방법 문자 "M"을 입력하십시오. 그것들을 메인 메뉴 페이지로 안내 할 것입니까?편지 "M"을 클릭하면 기본 메뉴로 돌아 오는 방법은 무엇입니까?
while (! inChoice.equalsIgnoreCase ("M"));을 (를) 사용해 보았습니다. 하지만 작동하지 않습니다. 어떤 생각이 잘못 됐나요?
공공 정적 무효 searchByCountry() {
int n, i, j, x;
n = (uniqueCountries.length)-1;
for(i=0; i<n; i++) {
for(j=i+1; j<n;) {
if(uniqueCountries[i]==uniqueCountries[j]) {
for(x=j; x<n; x++) {
uniqueCountries[x] = uniqueCountries[x+1];
}
n--;
}
else {
j++;
}
}
}
String msg = "";
msg = "";
for(i=0; i<n; i++) {
String allUniqueCountries = uniqueCountries[i];
msg += (i+1) + ". " + allUniqueCountries +" "+ "\n";
}
문자열 입력 JOptionPane.showInputDialog = (null의, + MSG "를 국가 번호 \ 입력 없음");
int countryChoice = Integer.parseInt(input);
String result = "";
int count = 1;
if(countryChoice == 1) {
for(i=0; i<3; i++) {
JOptionPane.showInputDialog(null, "Search result: " + count + "\n"
+ "=======================\n"
+ "Country: " + country[i] + "\n"
+ "Month: " + travelmonth[i] + "\n"
+ "Description: " + description[i] + "\n"
+ "Price: $" + price[i] + "\n" + "=======================\n"
+ "Enter M to return to main menu");
count++;
}
}
//else if
if (countryChoice == 2) {
for(i=3; i<5; i++) {
JOptionPane.showInputDialog(null, "Search result: " + count + "\n"
+ "=======================\n"
+ "Country: " + country[i] + "\n"
+ "Month: " + travelmonth[i] + "\n"
+ "Description: " + description[i] + "\n"
+ "Price: $" + price[i] + "\n"
+ "=======================\n"
+ "Enter M to return to main menu");
count++;
}
}
다른 경우 (countryChoice의 == 3) {
for(i=5; i<8; i++) {
JOptionPane.showInputDialog(null, "Search result: " + count + "\n"
+ "=======================\n"
+ "Country: " + country[i] + "\n"
+ "Month: " + travelmonth[i] + "\n"
+ "Description: " + description[i] + "\n"
+ "Price: $" + price[i] + "\n"
+ "=======================\n"
+ "Enter M to return to main menu");
count++;
}
}
while(!inChoice.equalsIgnoreCase("M"));
}
} 당신은 실제로 새로운 입력을하고 "M"을 일치하면 확인해야합니다
코드/콘텐츠를 추가하려면 게시물을 수정하십시오. – Zachary
@Zachary 편집 됨 – Cherlyn
inChoice는 어디에 있고 잠시 (...) 언급하지 않습니까? 게시 한 콘텐츠가 관련성이 있습니까? 사용자로부터 입력을 받으면 그것이 M인지 확인하는 것이 가장 좋은 방법입니다. – Zachary