Results 1 to 5 of 5
  1. #1
    gandalf5166 is offline Member
    Join Date
    Feb 2010
    Posts
    75
    Rep Power
    0

    Unhappy Seriously weird output

    Hey, I'm getting this for my output.
    Usage: java [-options] class [args...]
    (to execute a class)
    or java [-options] -jar jarfile [args...]
    (to execute a jar file)

    where options include:
    -client to select the "client" VM
    -server to select the "server" VM
    -hotspot is a synonym for the "client" VM [deprecated]
    The default VM is client.

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
    A ; separated list of directories, JAR archives,
    and ZIP archives to search for class files.
    -D<name>=<value>
    set a system property
    -verbose[:class|gc|jni]
    enable verbose output
    -version print product version and exit
    -version:<value>
    require the specified version to run
    -showversion print product version and continue
    -jre-restrict-search | -jre-no-restrict-search
    include/exclude user private JREs in the version search
    -? -help print this help message
    -X print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
    enable assertions
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
    disable assertions
    -esa | -enablesystemassertions
    enable system assertions
    -dsa | -disablesystemassertions
    disable system assertions
    -agentlib:<libname>[=<options>]
    load native agent library <libname>, e.g. -agentlib:hprof
    see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
    load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
    load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
    show splash screen with specified image

    Process completed.
    My code is:
    import java.lang.Math;
    import java.util.Scanner;
    /**
    * @(#)Mastermind.java
    *
    * Mastermind application
    *
    * @author
    * @version 1.00 2010/2/23
    */
    public class Mastermind {

    public static void Main(String[]args) {
    int number;
    int r1;
    int r2;
    int r3;
    int r4;
    int g1;
    int g2;
    int g3;
    int g4;
    int bulls;
    int cows;
    int guess;
    final int SENTINEL = 0;
    int retry = 1;
    Scanner input = new Scanner(System.in);
    do{

    number = (int)(9999 * Math.random() + 0000);
    r4 = number % 10;
    number /= 10;
    r3 = number % 10;
    number /= 10;
    r2 = number % 10;
    number /= 10;
    r1 = number % 10;
    bulls = 0;
    cows = 0; //determine the number and reset the bulls and cows
    for (int turn = 1; turn <= 10; turn++) {
    System.out.println("Turn " + turn); // tell the user what turn he is on
    System.out.println("Please enter your guess (i.e. 1445): ");
    guess = input.nextInt();
    g4 = number % 10;
    number /= 10;
    g3 = number % 10;
    number /= 10;
    g2 = number % 10;
    number /= 10;
    g1 = number % 10; //evaluate the users guess into single digits
    if (g1 == r1)
    bulls++;
    else if (g1 == r2 || g1 == r3 || g1 == r4)
    cows++;
    if (g2 == r2)
    bulls++;
    else if (g2 == r1 || g2 == r3 || g2 == r4)
    cows++;
    if (g3 == r3)
    bulls++;
    else if (g3 == r1 || g3 == r2 || g3 == r4)
    cows++;
    if (g4 == r4)
    bulls++;
    else if (g4 == r1 || g4 == r2 || g4 == r3)
    cows++;
    System.out.println("Number of bulls: " + bulls);
    System.out.println("Number of cows: " + cows); //check the guess and tell the user how close he was

    if (bulls == 4)
    {
    System.out.println("Code broken by trying " + turn + " times.");
    turn = 10; //tell the user that he has won
    }
    else
    {
    bulls = 0;
    cows = 0; //reset bulls and cows for next guess
    }
    if (turn == 10 && bulls != 4)
    {
    System.out.println("Failed to break the code. ");
    System.out.println("The answer is: " + r1 + r2 + r3 + r4);
    System.out.println("Enter 0 to quit, anything else to continue.");
    retry = input.nextInt(); //tell the user he has lost and ask for a retry
    }
    }
    } while (retry != SENTINEL);
    }
    }

  2. #2
    gandalf5166 is offline Member
    Join Date
    Feb 2010
    Posts
    75
    Rep Power
    0

    Default

    sorry my post is so long, i couldn't put my code as an attachment

  3. #3
    gandalf5166 is offline Member
    Join Date
    Feb 2010
    Posts
    75
    Rep Power
    0

    Default

    I'm having the same problem with a couple other programs by the way, so I'm not entirely sure where the common ground is.

  4. #4
    gandalf5166 is offline Member
    Join Date
    Feb 2010
    Posts
    75
    Rep Power
    0

    Default

    bump? are all the people here takin a crap or something?

  5. #5
    gandalf5166 is offline Member
    Join Date
    Feb 2010
    Posts
    75
    Rep Power
    0

    Default

    Sorry I'm kinda tense. This is due tomorrow night and I really have no idea what's going on.

Similar Threads

  1. weird problem
    By GPB in forum New To Java
    Replies: 2
    Last Post: 02-28-2010, 12:04 PM
  2. Java, output string, getting correct output? HELP!
    By computerboyo in forum New To Java
    Replies: 2
    Last Post: 02-25-2009, 11:44 PM
  3. Weird Error?
    By sciguy77 in forum New To Java
    Replies: 4
    Last Post: 01-20-2009, 02:32 AM
  4. Weird data output
    By Shaolin in forum New To Java
    Replies: 12
    Last Post: 12-11-2007, 04:27 PM
  5. weird looking shape JButton is it possible?
    By unhurt in forum AWT / Swing
    Replies: 8
    Last Post: 11-03-2007, 09:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •