I tried this,
but I need to define the String nr1 before the if-statement. How can I do this?System.out.println("Enter your number: "); nr1 = scn.nextDouble(); if(nr1.equals("stop") || nr1.equals("Stop")){ String nr1 = nr1(double); System.exit(0); }
Also, is there any other way to do this? As in if I write stop in any place it will shutdown the program?
EDIT:
I want the nr1 to be converted from a double to a string in the if-statement. I do not want it to be converted so it will work outside the if-statement, as it will only ruin the rest of my code.