Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8631047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:09:45+00:00 2026-06-12T09:09:45+00:00

`I just finalized the guessing game in java, but now i need to create

  • 0

`I just finalized the guessing game in java, but now i need to create a highs core for this game, that will store the Name, Time and Number of Guesses even after the code is stopped (im using eclipse). can anyone help me with a high score table? this is the game:

import java.util.*;

public class Game {

public static void main (String[]args){
    Game guessing = new Game();
    guessing.start();

}
public void start() {

    System.out.println("Welcome to guessing game!"); 
    System.out.println("Please enter the number between 1 and 1000");

    Scanner input = new Scanner(System.in);
    String y = "yes";
    String n = "no";    
    String playerName;
    String currentGuess;
     String quit = "quit";
     int tries = 0;  //number of times player guessed
     int guess = 0;  //number that player inputs
     long startTime = System.currentTimeMillis();  //start timer after first guess
     int randomNumber = (int) (Math.random() * 999 + 1); // generating random number
     System.out.println(randomNumber);     // to be deleted after game is finished
     currentGuess = input.nextLine();


do{


    if (currentGuess.matches("[0-9]+")) {  //if input is non-numeric value, show message
        int numericInput = Integer.parseInt(currentGuess);
    }
    else {
    System.out.println("You have enetered non-numeric value,please try again");
    currentGuess = input.nextLine();
    continue; //allows to enter non-numeric values multiple times without crash
    }

    guess = Integer.parseInt(currentGuess);


    if(guess<1 || guess>1000 ){ //if the input number is out of range
        System.out.println("The number is out of range! Please try again");
        currentGuess = input.nextLine();
        continue;
    }

    if (guess>randomNumber){
        System.out.println("Oops,too high!");
        currentGuess = input.nextLine();
        tries++;
    }
    else if (guess<randomNumber){
        System.out.println("Sorry, to low!");
        currentGuess = input.nextLine();
        tries++;
    }



    if(currentGuess.equalsIgnoreCase(quit)){
        System.out.println("*****Thanx for playing! See you next time!*****");
    }

    if (guess==randomNumber){
        tries++;
        long endTime = System.currentTimeMillis();//stop the timer after number is guessed         correctly
        long gameTime = endTime - startTime; //display game time after input number==random   number
        System.out.println("Well done! You won the game in " + tries + " guesses " + "and " +    gameTime/1000 +  " seconds!");
        System.out.println("Please enter your name: ");
        playerName = input.nextLine();    //input for player name
        System.out.println("Would you like to play again? y/n..."); 
                currentGuess = input.nextLine();
                }                              /*input for "yes" or "no".. 
                                                  *MUST type "yes" or "no"! instead of "y" or   "n"!!*/

    if (currentGuess.equalsIgnoreCase(n)){
        System.out.println("******See you next time");

    }

    if (currentGuess.equalsIgnoreCase(y)) {
        start();

    }
    }

while(guess!=randomNumber && !currentGuess.equalsIgnoreCase(quit));  /*keep running the loop    until input
                                                                 *equals random number, or until   input equals
                                                                 * "quit" */


}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:09:46+00:00Added an answer on June 12, 2026 at 9:09 am

    You can save the results to a txt file in the user directory. and when your program starts you can read it when initializing the program. Example for writing text file

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I spent hours trying to fix that but I've just given up; I have
Just checking my JS and I have an error, but I cannot see where.
Just learning the world of jquery, and all my googling gives examples like this:
Just see this: SELECT clientid,clientname,startdate,enddate,age FROM clients WHERE clientid IN (1,2,3,4,5) AND CASE WHEN
Just a simple question, but can't get an answer on my own. In memory
I need help with some programming logic... I need to loop this method to
Just for the sheer heck of it, I've decided to create a Scheme binding
I have finalized a small PHP application that can serve many documents. These documents
I'm trying to write a Java unit test that tests the effects of a
I'm working on a new Asp.Mvc3 application that will go line about the same

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.