enter import java.io.*;
class eval
{
double add(double a,double b)
{
return (a+b);
}
double sub(double a,double b)
{
return (a-b);
}
double mul(double a,double b)
{
return (a*b);
}
double div(double a,double b)
{
return (a/b);
}
}
class cal extends eval
{
public static void main(String args[])throws IOException
{
eval a1=new eval();
try{
System.out.println("1) Add");
System.out.println("2) Subtract");
System.out.println("3) Multiply");
System.out.println("4) Divide");
System.out.println("5) Enter your choice");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int ch;ch=Integer.parseInt(br.readLine());
System.out.println("Enter two number");
double a;a=Integer.parseInt(br.readLine());
double b;b=Integer.parseInt(br.readLine());
switch(ch)
{
case 1:
a1.add(a,b);
break;
case 2:
a1.sub(a,b);
break;
case 3:
a1.mul(a,b);
break;
case 4:
a1.div(a,b);
break;
}
}
catch (IOException e)
{
System.out.println("Error occured, please restart application.");
}
}
}
答案 0 :(得分:4)
你试图像这样运行它:
java cal.class
您应该只指定类名而不是文件名称:
java cal
(我怀疑你可能还有更多关于实际代码的问题,但请使用其他问题。首先,cal
没有理由延长eval
...而你可能会考虑更有意义的名字。)