Algorithm Sample - Absolute value of a math function


package algorithmsample24;

import java.util.Scanner;

/**
 *
 * @author Nurhak
 */
public class AlgorithmSample24 {

    public static void main(String[] args) {
        int number1 = 0;
        int number2 = 0;
        int subResult = 0;
        String data = "";

        try {
            Scanner scan = new Scanner(System.in);
            System.out.println("Please enter the first number.");
            data = scan.nextLine();
            number1 = Integer.parseInt(data);

            System.out.println("Please enter the second number.");
            data = scan.nextLine();
            number2 = Integer.parseInt(data);

            subResult = number1 - number2;
            System.out.println("Absolute value of subtraction is: " + Math.abs(subResult));
        } catch (Exception e) {
            System.err.println(e.toString());
        }
    }
}

Comments

Popular posts from this blog

Solution for the fault: "System.Diagnostics.Process.Start is not working on IIS, but working on ASP.NET Development Server"

Solution for "Can not obtain Oracle client information from registry"