我想通過指令方法打印菜單,但程序不執行任何操作。任何人都可以告訴我如何解決這個問題。java中的菜單方法
這裏是類方法聲明..
public class Factorial
{
public void instructions()
{
System.out.printf("Enter your choice:\n",
" 1 to calculate a factorial value of an integer.\n",
" 2 to calculate mathematical constant e.\n",
" 3 to calculate e^x.\n",
" 4 to end.\n");
} // End of instructions
}
這裏是調用從階乘的課堂教學方法爲主。
import java.util.Scanner; // Program uses scanner.
public class behzat
{
private static Scanner input;
public static void main(String[] args)
{
Factorial myfactorial = new Factorial();
myfactorial.instructions();
}
}
我不知道它是否是錯字,但'factorial'應該是'Factorial'。如果你的代碼按照現在的方式進行編譯,那麼它可能就是世界末日的標誌。 – Maroun 2013-03-26 22:04:59
什麼問題,創建一個階乘對象,調用指令方法,只要你想打印指令菜單 – 2013-03-26 22:06:04
你的代碼是否編譯?你的課是'F'actorial而不是'f'actorial。 – A4L 2013-03-26 22:06:58