import javax.swing.JOptionPane;
public class xunhuan6
{
public static void main(String[] args)
{ int a,b;int i=0;int c=0;int d=0;String out="";
String temp=JOptionPane.showInputDialog("Input a number:");
try{i=Integer.parseInt(temp); }
catch(Exception e)
{JOptionPane.showMessageDialog((null),"error,you should put int number","error",0);System.exit(0);}
if(i<=0)
{JOptionPane.showMessageDialog((null),"error,:i<=0!","error",0);
System.exit(0);}
if(0=3)
{a=1;b=1;
for(c=i;c<3;c--)
{
d=a+b;
a=b;
b=d;
}
out += i+"的斐波那契数是:"+d;
JOptionPane.showMessageDialog((null),out,"斐波那契数",1);
}
}
}
说错了是d的值
|