我對Java真的很陌生,大部分知識都是自學的。你能幫我弄清楚這一點嗎?我可以在這裏使用「返回」或任何想法?
我們的老師希望我們製作一個關於Java的菜單。在哪裏輸出這樣的東西..
菜單 1 - Java的歷史 2- Java的關鍵字 3 - Java數組等。 。
你想讀一個(是/否): 如果是//
請輸入菜單號: //那麼它會顯示一個信息..
//我的問題是,我怎麼能在新輸入的值連接到第一個方法,這樣我就不會擁有遍佈再寫一遍......
這是什麼在我的心.. ,但即時通訊卡..
import java.util.Scanner;
public class Program {
public static void main (String [] args) {
System.out.println("Please enter a number:");
int x = nextInt();
if (x == 1) {
for (int x = 5; x == 5;x++) // array of 1(first menu)
System.out.println ("Do you want to read another? (Yes/No):");
System.out.println ("Please enter a menu number:")
// return to if with it's new entered value....
}
else if (x == 2) {
for loop of array 2
System.out.println ("Do you want to read another? (Yes/No):");
System.out.println ("Please enter a menu number:")
// return to if with it's new entered value....
}
else if (x == 3) {
for loop of array 3
System.out.println ("Do you want to read another? (Yes/No):");
System.out.println ("Please enter a menu number:")
// return to if with it's new entered value....
else if (x ==4) {
for loop of array 4
else if (x == 5) {
for loop of array 5
else if (x == 6) {
for loop of array 6
else if (x == 7) {
for loop of array 7
else if (x == 8) {
for loop of array 8
else if (x == 9) {
for loop of array 9
else if (x == 10) {
for loop of array 10
else {
//exit the program
你需要一個while循環嗎? – ergonaut