So I wanted to make a simple number guessing game, which worked fine. Then I wanted to add a play again function, but... I get errors. Why? Here's the code:
import java.util.*; public class main { public static void main(String args[]) { numberk(); } public static void numberk() { int nummer = (int)(Math.random()*100)+1; int trys = 0; int highscore = 100; int guess; Scanner sc = new Scanner(System.in); System.out.println("Guess the number!"); do { guess = sc.nextInt(); if (nummer > guess) { System.out.println("Go higher!"); trys = trys + 1; } if (nummer < guess) { System.out.println("Go lower!"); trys = trys + 1; } if (nummer == guess) { System.out.println("You guessed the right number in " + trys + " trys!"); if (trys < highscore) { highscore = 0 + trys; } System.out.println("Your highscore was " + highscore + " trys!"); } } while (guess != nummer); nommal(); } public static void nommal() { String nochmal; Scanner again = new Scanner(System.in); System.out.println(""); System.out.println("Again? Type in yes or no."); nochmal = again.toString(); if (nochmal == "y" || nochmal == "yes") { numberk(); } if (nochmal == "n" || nochmal == "no") { System.exit(0); } else { nommal(); } } }