import java.util.Scanner;class calculator { void add(float a, float b) { System.out.print("Result: "+(a+b)); } void sub(float a, float b) { System.out.print("Result: "+(a-b)); } void mult(float a, float b) { System.out.print("Result: "+(a*b)); } void div(float a, float b) { System.out.print("Result: "+(a/b)); }}class Cal { public static void main(String args[]) { Scanner sc= new Scanner(System.in); do { System.out.print("Enter Two Operands: "); float a=sc.nextFloat(); float b=sc.nextFloat(); System.out.print("Press 1 for Addition\n Press 2 for Subtraction\n Press 3 for Multiplication\n Press 4 for Division\n Press 5 for Exit\n"); System.out.print("Enter your choice: "); int n=sc.nextInt(); calculator c=new calculator(); switch(n) { case 1: c.add(a,b); break; case 2: c.sub(a,b); break; case 3: c.mult(a,b); break; case 4: c.div(a,b); break; case 5: System.exit(0); default: System.out.print("Wrong Choice!!!"); } System.out.print("Are you want to continue?: "); int con=sc.nextInt(); } while (con==1); }}这是简单的计算器问题,但我遇到以下错误:PS H:\java> javac calculator.javacalculator.java:47: error: cannot find symbol }while(con==1); ^ symbol: variable con location: class Cal1 error
添加回答
举报
0/150
提交
取消