高人们来帮帮我啊,我都要被异常处理搞死了~~~~~~~~~~~~~~
编写一个简单的四则运算器,
public class inputException extends Exception
{
public inputException()
{
super();
}
public inputException(String s)
{
super(s);
}
}
存为文件inputException.java然后编译
public class works
{
public double work(double x,String a,double y) throws inputException
{
if(a== "+ ")
{
return x+y;
}
else
{
if(a== "- ")
{
return x-y;
}
else
{
if(a== "* ")
{
return x*y;
}
else
{
if(a== "/ ")
{
return x/y;
}
else
{
throw new inputException( "inputing error!!!!!!! ");
}
}
}
}
}
}
存为works.java然后编译
最后将
public class calculator
{
public static void main(String args[])
{
if(args.length==3)
{
works working=new works();