please can someone help me with this HW
the instructions are :
# The computer should ask the player for the largest possible value which could be generated (N)
# The maximum number of guesses should be set equal to 1/2 N. (Don't prompt the user).
# When the game starts, the top 5 high scores should be displayed.
* At the beginning of a round, the high scores will be read from a file into an array
o You can decide where this file is to be stored. You DON'T need to prompt the user to find it.
o Tip: If you wish to use relative paths for your file location... it can be tricky.
* The High-Scores should be displayed in descending order.
* The high-score file just contains a series of integers.
o For simplicity, no other information will be stored.... just the scores themselves.
o (See the sample file below)
# The player should be asked to guess a number between 1 and N.
* The user should receive feedback pertaining to whether their guess is too high or too low.
# The player should be able to enter guesses until:
* The correct number is guessed
* The guess limit is reached
* The user enters a negative number to quit the round.
# Once a round is quit, the player should be prompted to play another round.
# Once a round ends:
* The player should be shown their score using the following formula:
o Score = (Maximum Value) / (Number of Guesses to get Correct)
o Score = 0 if the user quits before getting the correct answer or exceeds the maximum number of guesses.
o Round the score to the nearest integer
* If the players score is higher than the lowest score in the "high-score" file:
o A new high-score file should be written over the old one.
# The user should be prompted to play again.
* The should be able to answer in upper or lower case
* The continued game should use the same upper bound and max guesses as entered at the beginning.
* Before staring the each round, the current high scores should
be displayed.
Here wat i have done so far:
import java.io.*;
import java.util.*;
public class trial{
public static void main(String[] args) throws FileNotFoundException {
Scanner input = new Scanner(new File("highscores.txt"));
Scanner console = new Scanner(System.in);
System.out.println(" Game Setup:");
System.out.println(" I will pick a random number between 1 and N");
System.out.println(" Please enter a value for N: ");
int N= console.nextInt();
System.out.println();
readScores(input);
Random r= new Random();
int result = 0;
String ans;
int maxGuesses = N/2;
System.out.println();
System.out.println("I'm thinking of a random Number between 1 and " + N + ".");
System.out.print("You have " + maxGuesses + " chances to guess the number.");
System.out.println(" Enter -1 at anytime to quit.");
int guessNum = 0;
for(int i= 1; i <= maxGuesses; i++) {
System.out.println("Enter guess number " + i + " :");
guessNum= console.nextInt();
result = r.nextInt(N);
if(guessNum < result) {
System.out.println("Your guess is too low.");
} else if(guessNum >result){
System.out.println("Your guess is too high.");
} if(guessNum == result) {
System.out.println("Congratulations, you guessed the correct value in " + i + " tries!");
int score = N/i;
System.out.println("Your score is " + score + " points. You did not beat a high score.");
PrintStream output = new PrintStream(new File("Highscores.txt"));
output.println(score);
break;
}
}
if (guessNum != result) {
System.out.println("Sorry, you failed to guess the correct number!");
}
}
public static void readScores(Scanner input) {
System.out.println("Highscores: ");
while(input.hasNextInt()) {
int next = input.nextInt();
System.out.println(next);
}
}
}