-5
當我把第一個數字大於第二個數字時,程序不輸出任何東西,它只是空白。每當第一個數字越大,它就不能工作
import javax.swing.*; //for JFrame and JPanel
import java.text.*; //for text
public class number6{ //states class name
public static void main (String [] args){ //starts program
String firstStr, secondStr; //states string variables
int first, second; //states integer variables
DecimalFormat df = new DecimalFormat("0.000");
firstStr = JOptionPane.showInputDialog(null, "Enter first number:"); //asks for first number
first = Integer.parseInt(firstStr); //makes first number from string to integer
secondStr = JOptionPane.showInputDialog(null, "Enter second number:"); //asks for second number
second = Integer.parseInt(secondStr); //makes second nubmer from string to integer
for(int x = first; x <= second; x++){
if(first != 0){ //doesn't show 0
System.out.print(x + " "); //output statement
}
}
}
}
請解決您的壓痕。這是不可讀的,只會讓你更難。 – f1sh
「程序不起作用」 - 你能解釋一下這意味着什麼嗎?你是否收到錯誤信息?你的鍵盤着火嗎?華夫餅燒了嗎? – bradimus
如果第一個數字較大,您希望它做什麼? – JJJ