Hi I'm really new to java and is trying stuff out as I learn them. I'm trying to make a calculator where you type in two numbers and they get added toghether. For some reason it doesn't work and the program is making up numbers of its' own! I really have no idea why. I'll post the hole code since it isn't big:
Code:
    public static void main (String [] args)throws Exception {
        
        int sum=0;
        int num1=2;
        int num2=2;
        char choice ='R';
       
        
        
        System.out.println("Type in your first number");
        System.out.flush();
        num1=(int)System.in.read();
        System.out.println("Type in your second number");
        System.out.flush();
        num2=(int)System.in.read();
        System.out.println("You now have the numbers" + num1);
        System.out.println("and" +num2);
        
        choice=(char)System.in.read();
        
        if ( choice == 'A' ) {
            sum=num1+num2; 
            System.out.println(sum);
        }
        
    }
    
}
The if statement is there because I want to add the option to choose what to do with the numbers but first I need this to work. What happens when I run the program is that it asks for my first number like it's supposed to and I enter it. The it askes for my second number but at the same time moves on to the other part. I entered a 5 as my first number and it looks like this:
Type in your first number
5
Type in your second number
You now have the numbers53
and 10


Anyone knows what I've done wrong? Thanks..

[ArchAngel added CODE tags]