我正在尝试制作一个简单的计算器程序,并且基本功能有效,但我正在尝试在程序末尾实现“您想要执行其他操作吗”,以便如果答案是“则它会关闭” t y。说我的“yesorno”无法解析为变量
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
do {
System.out.println("Enter 2 numbers");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int numero1=Integer.parseInt(br.readLine());
BufferedReader br2=new BufferedReader(new InputStreamReader(System.in));
int numero2=Integer.parseInt(br2.readLine());
System.out.println("Select an operation");
BufferedReader br3=new BufferedReader(new InputStreamReader(System.in));
char Operacija=(char)br3.read();
switch (Operacija)
{
case '+':
System.out.println(numero1+numero2);
break;
case '-':
System.out.println(numero1-numero2);
break;
case '/':
System.out.println(numero1/numero2);
break;
case '*':
System.out.println(numero1*numero2);
break;
default:
System.out.println("Illegal operation");
}
BufferedReader br4=new BufferedReader(new InputStreamReader(System.in));
char yesorno=(char)br4.read();
}while (yesorno=='y');
}}
智慧大石
慕侠2389804
相关分类