Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: the codes.. needed the errors the points and i want to play again.. how should i do..?

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Thanked 0 Times in 0 Posts

    Default the codes.. needed the errors the points and i want to play again.. how should i do..?

    import java.util.Random;
    import java.util.Scanner;

    public class John {

    public static void main(String[] args) {

    System.out.println("Welcome to guessing game!");

    Random rand = new Random();
    int numberToGuess = rand.nextInt(10);
    int numberOfTries = 0;
    Scanner input = new Scanner(System.in);

    int guess;
    int Round;
    int target;
    int points;
    char play;
    int error;

    while (Round<=3){
    target = rand.nextInt(9) + 1;
    System.out.println("please enter a number betwwen 1 to 10");
    guess = input.nextInt(10);

    if (guess == numberToGuess){
    System.out.println("you win!");
    System.out.println("the number was " +numberToGuess);
    else if(guess < numberToGuess){
    System.out.println("your guess is too low");
    else if (guess > numberToGuess){
    System.out.println("your guess is too high");

    System.out.println("your points");
    System.out.println("you have"+""+points+""+"pts.");
    System.out.println("you commited"+error+""+ "errors");
    System.out.println("It took you " + numberOfTries + " tries");
    System.out.println("Game over");
    System.out.print("do you want to play again?:");

    System.out.println("Thank you!");

  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Washington, DC
    My Mood
    Thanked 632 Times in 540 Posts

    Default Re: the codes.. needed the errors the points and i want to play again.. how should i do..?

    When posting code, please use the highlight tags to preserve formatting.

    What does this code do? Do you receive a compiler error? A run-time error? Something else? What's your question?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Replies: 1
    Last Post: November 6th, 2013, 01:48 AM
  2. software can discover the errors of java codes ?
    By websit in forum What's Wrong With My Code?
    Replies: 14
    Last Post: November 1st, 2011, 08:34 PM
  3. getting errors needed to be clear
    By erinbasim in forum Enterprise JavaBeans
    Replies: 1
    Last Post: February 4th, 2010, 02:24 AM
  4. Urgent Help needed with java codes
    By makarov in forum Java Theory & Questions
    Replies: 0
    Last Post: November 13th, 2009, 06:23 AM