Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
coding in java
#11
my source code as in my java program code? cause my program is extreamly long.... well its a few hundred lines long lol
Reply
#12
That's why I said the *relevant* source code, not the entire one. ;) My guess is that you assign the input directly to an integer variable though it gets read as a string. Maybe your Windows JVM automatically converts the input. But show me the source, Luke. :)
Reply
#13

here it is the menu part



Code:
/Main Menu

    System.out.println ("Please select a option");

    System.out.println ("1. Play Game");

    System.out.println ("2. Instructions");

    System.out.println ("3. High Scores");

    System.out.println ("4. Exit");

    intInput = reader.readInt();

    //Menu Choices

    if (intInput == 1){

        PlayGame();

    }else if (intInput == 2){

        strInstructions();

    }else if (intInput == 3){

        HighScores();

    }else if (intInput == 4){



    }




Reply
#14

The data type of your "reader" variable would be interesting, too. I just wrote a small example that *should* work (will test it later, not too much time at the moment):

 



Code:
import java.io.*;

public class myinput {
    static public void main(String[] args) {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            int someint = 0;

            System.out.print("Number: ");

            try {
                    someint = Integer.parseInt(reader.readLine());
            } catch (IOException e) {
                    System.out.println("Input error...");
                    System.exit(1);
            }

            System.out.println("Entered "+someint+".");
    }
}




Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)