How do I check if a variable is equal or not equal to a contains? I want to make it so if someone where to put in an invalid operator it would say try again.
String operator = "+, -, *,/, %";
double num1, num2, sum=0;
System.out.println("First number: ");
num1 = input.nextDouble();
System.out.println("Second number: ");
num2 = input.nextDouble();
if (operator.contains("+")){
sum = num1 + num2;
} else if (operator != operator.contains("+,-,*,/,%"){
System.out.println("Error"); }