public class NegateExactMethod { public static void main(String[] args) { // Ask for user input System.out.print("Enter an input:"); // use scanner to read the console input Scanner scan = new Scanner(System.in); // Assign the user to String variable String s = scan.nextLine(); // close the scanner object scan.close(); // convert the string input to double int value = Integer.parseInt(s); // get the result of decrementExact int result = Math.negateExact(value); System.out.println("Result of the operation is " + result); } }
No comments:
Post a Comment