Wednesday, 15 February 2017

Math : SubstractExactMethod


public class SubstractExactMethod {

    public static void main(String[] args) {

        // Ask for user input

        // use scanner to read the console input        Scanner scan = new Scanner(System.in);
        // Assign the user to String variable        System.out.print("Enter X value input:");        String s = scan.nextLine();        System.out.print("Enter Y value input:");        String s1 = scan.nextLine();
        // close the scanner object        scan.close();
        // convert the string input to double        int valueX = Integer.parseInt(s);        int valueY = Integer.parseInt(s1);
        // get the result of decrementExact        int result = Math.subtractExact(valueX, valueY);        System.out.println("Result of the operation is " + result);
    }
}

No comments:

Post a Comment