Я делаю игру «Угадай число», и это мой код для игры.
import java.util.Random;
import java.util.Scanner;
public class Guess {
public static void main(String[] args) {
int guess, diff;
Random random = new Random();
Scanner in = new Scanner(System.in);
int number = random.nextInt(100) + 1;
System.out.println("I'm thinking of a number between 1 and 100");
System.out.println("(including both). Can you guess what it is?");
System.out.print("Type a number: ");
guess = in.nextInt();
System.out.printf("Your guess is: %s", guess);
diff = number - guess;
printf("The number I was thinking of is: %d", guess);
printf("You were off by: %d", diff);
}
}
Однако, когда я пытаюсь ее скомпилировать, появляется следующая ошибка:
Guess.java:20: error: cannot find symbol
printf("The number I was thinking of is: %d", guess);
^
symbol: method printf(String,int)
location: class Guess
Guess.java:21: error: cannot find symbol
printf("You were off by: %d", diff);
^
symbol: method printf(String,int)
location: class Guess
2 errors
Что не так с кодом?