How to make x is a whole number a condition in Java
<p>I'm writing a decimal to binary to octal to hexadecimal to base 20 (I added up to base 36 functionality) calculator for school. It works and catches a few exceptions, except it does something weird when a decimal (like 4.5, not the number system) value is input. I want it to just catch it and take the user back to the top of my code and say "please try again and input a whole number", I'm thinking I should use an if statement to do that and I just need to know how to make "x is a whole number" a condition. I'm using Java by the way.</p>

<p>This is the part of my code I'm working on:</p>

<pre><code>public class mainconvert //creates my main class

{ //start mainconvert

    public static int manualparse(String m)//initializes an int method for a manual parse instead of using the library
    {//start manualparse

        int parsedvalue = 0;//creates an int that the parsed value will go into
        char[] split = m.toCharArray();//takes the input and splits it into an array of characters so we can take each individual character and convert it to an int
        int n = 0;//creates an int that will be used for the power that 10 is raised to while converting the input place

        for(int o=m.length()-1; o&gt;=0; o--)//creates a for loop that takes each place in the array and loops through the conversion process until every place is converted
        {//start conversion for
            parsedvalue += Math.pow(10,n)*(split[o]-'0');//does the math, takes the char in each place, gets its ascii value, subtracts ascii 0 from that and multiplies it by 10^n, seen previously
            n++;//increases n (the exponent) by 1 after each loop to match the place that is being worked on
        }//end conversion for

        return parsedvalue;//returns the final parsed value
    }//end manualparse

    public static void main(String args[])//creates the main entry point
    {//start main

        JOptionPane pane = new JOptionPane();//makes JOptionPane "pane" so I don't have to type out "JOptionPane"

        boolean binput = false;

        do{//start do for do while loop for the reset on the exception catcher

            try{//start try for exception catcher

                String input = pane.showInputDialog("Enter value for conversion");//makes a Jpane with an input box for the value to be converted
                StringTokenizer toke = new StringTokenizer(input);//makes a string tokenizer for the input
                String k = toke.nextToken();//uses toke.nextToken to grab the token put into the input box so it can be used, it is made into a string
                int x = manualparse(k);//uses the manual parsing method created earlier to parse the token grabbed in string k into an int for use in our conversions

// then a bunch of calculator stuff and here's the end of the try/catch and do while loop

}//end try for exception catcher

catch(Exception ex)//catches exception

{//start catch

binput = true;//changes boolean to true to trigger do while loop

pane.showMessageDialog(null, "Please try again and input an integer");//displays error

}//end catch

}while(binput==true);//while for do while loop, triggers while the boolean binput is true
</code></pre>
