System.in.read() method

后端 未结 6 1383
太阳男子
太阳男子 2020-12-02 03:03

Following is the code, I have written to get two inputs from user. But when I run the program, It takes only one input and generate other by itself and calculate the wrong v

6条回答
  •  醉酒成梦
    2020-12-02 03:33

    hey bro this should work for what you need i think if its not let me know

    import java.io.IOException;
    import java.util.Scanner;
    
    public class noob{
    
    
    class ThrowsExcpt {
        int divide(int x, int y) throws ArithmeticException, IOException {
            return x / y;
        }
    }
    
    class ThrowsTemps {
        public void main(String s[]) throws IOException {
    Scanner sc = new Scanner(System.in);
    System.out.println("Enter number 1");
            int x = sc.nextInt();
     System.out.println("Enter number 2");
            int y = sc.nextInt();
    

提交回复
热议问题