I am not sure why I get continuing told the error of java22 in my code. I searched other person's question like around. like here Compiler error: "class, interface, or enum expected"
But I could not find suitable answer for this. It seems like error not only class, interface or enum import part. Some cording has issue it. But but if so I would like to know, which part is course of the problem in this case?
Also, I would like to know the if I want disable to use the num2 for case2. Since it is factorial, it should ask only num1.
Thank you for all the help.
This is the message
Calc.java:22: error: class, interface, or enum expected
import java.util.*;
^
1 error
This is a code part
import java.util.*;
public class Calc
{
public static void main(String[] args)
{
NumCalc calc = new NumCalc();
System.out.println("Welcome to Math NumCalc!\nPlease choose an option:"
+ "\n\t1 " + "- add two real numbers"
+ "\n\t2 " + "- subtract two real numbers"
+ "\n\t3 " + "- multiply two real numbers"
+ "\n\t4 " + "- devide two real numbers"
+ "\n\t5 " + "- get the factorial of an number"
+ "\n\t6 " + "- menu"
+ "\n\t0 " + "- exit"
);
calc.run();
}
}
import java.util.*;
public class NumCalc
{
private int option = -1;
private Scanner scan, num1, num2;
//private int opt;
double ans = 0.0;
//int category;
public NumCalc()
{
scan = new Scanner(System.in);
}
// entry point for class
public void run()
{
System.out.println("\n? " + scan);
int scan = scan.nextInt();
for (int i=0;i < count; i++)
{
option = option + scan.nextInt();
}
System.out.println("Enter 1st num:");
int num1 = scan.nextInt();
System.out.println("Enter 2nd num");
int num2 = scan.nextInt();
switch (option)
{
case 6:
ans = num1 + num2;
System.out.println(num1 + " + " + num2 + "=" + ans);
break;
case 5:
ans = num1 - num2;
System.out.println(num1 + " - " + num2 + "=" + ans);
break;
case 4:
ans = num1 * num2;
System.out.println(num1 + " * " + num2 + "=" + ans);
break;
case 3:
ans = num1 / num2;
System.out.println(num1 + " / " + num2 + "=" + ans);
break;
case 2:
num2 = boolean(false); // No 2nd number.
int ans = 1;
for (i = 1;i <= n; i++)
{
ans *= n;
}
break;
System.out.println("Factorial of" + num1 + " = ");
case 1:
//opt = opt + scan.nextInt();
continue;
default:
close();
}
}
}