Class JKNumbersUtil

java.lang.Object
com.jk.core.util.JKNumbersUtil

public class JKNumbersUtil extends Object
This class provides utility methods for performing mathematical operations on numbers.
Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    addAmounts(double num1, double num2)
    This method adds two double values and returns the result with three decimal places.
    static double
    divide(double n1, double n2)
    This method divides two double values and returns the result with three decimal places.
    static double
    fixAmount(double value)
    This method rounds a double value to three decimal places.
    static void
    main(String[] args)
    This main method is to demonstrate the functionality of the class.
    static double
    mutiply(double n1, double n2)
    This method multiplies two double values and returns the result with three decimal places.
    static double
    subAmounts(double n1, double n2)
    This method subtracts one double value from another and returns the result with three decimal places.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JKNumbersUtil

      public JKNumbersUtil()
  • Method Details

    • addAmounts

      public static double addAmounts(double num1, double num2)
      This method adds two double values and returns the result with three decimal places.
      Parameters:
      num1 - Specifies the first number.
      num2 - Specifies the second number.
      Returns:
      the result of adding the two provided numbers with three decimal places.
    • divide

      public static double divide(double n1, double n2)
      This method divides two double values and returns the result with three decimal places.
      Parameters:
      n1 - Specifies the numerator.
      n2 - Specifies the denominator.
      Returns:
      the result of dividing n1 by n2 with three decimal places.
    • fixAmount

      public static double fixAmount(double value)
      This method rounds a double value to three decimal places.
      Parameters:
      value - Specifies the input value to be rounded.
      Returns:
      the rounded value with three decimal places.
    • main

      public static void main(String[] args)
      This main method is to demonstrate the functionality of the class.
      Parameters:
      args - the command-line arguments.
    • mutiply

      public static double mutiply(double n1, double n2)
      This method multiplies two double values and returns the result with three decimal places.
      Parameters:
      n1 - Specifies the first number.
      n2 - Specifies the second number.
      Returns:
      the result of multiplying n1 and n2 with three decimal places.
    • subAmounts

      public static double subAmounts(double n1, double n2)
      This method subtracts one double value from another and returns the result with three decimal places.
      Parameters:
      n1 - Specifies the first number.
      n2 - Specifies the second number.
      Returns:
      the result of subtracting n2 from n1 with three decimal places.