java - Scanner "Input cannot be solved to a variable" error -


so i'm complete noob @ java , experimenting calculator. code below have far. problem code works until add label "loops:", after adding label scanner gets error reason. want loops label user can choose (if statement @ bottom of code) whether or not continue using calculator. appreciated.

import java.util.scanner;   public class mainclass {        public mainclass(){          loops:          scanner input = new scanner(system.in);           system.out.println("first number: ");         int number1 = input.nextint();         system.out.println("second number: ");         int number2 = input.nextint();         system.out.println("operator (+, -, /, *)");         string operation = input.next();         string cont = input.next();          int total;          if(operation.equals("+")){             total = number1 + number2;             system.out.println(total);         }         if(operation.equals("-")){             total = number1 - number2;             system.out.println(total);         }         if(operation.equals("*")){             total = number1 * number2;             system.out.println(total);         }         if(operation.equals("/")){             total = number1 / number2;             system.out.println(total);         }          system.out.println("continue? y/n: ");         if (cont.equalsignorecase("n")){             break loops;         }     }      public static void main(string[] args) {         new mainclass();       }  } 

you need use loop. labels exist though, no using them properly. labels can name loop can break / continue specific loops.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -