12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
-
- /**
- * Write a description of class calculatorCoreFunctions here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- import java.lang.*;
- import java.util.*;
- public class calculatorCoreFunctions
- {
- // instance variables - replace the example below with your own
-
- /**
- * Write a description of class calculatorCoreFunctions here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
-
- public calculatorCoreFunctions()
- {
- // initialise instance variables
- double x = 0;
- double y = 0;
- }
-
- /**
- * An example of a method - replace this comment with your own
- *
- * @param y a sample parameter for a method
- * @return the sum of x and y
- */
- public double add(double x, double y)
- {
- // put your code here
- return x + y;
- }
-
- public double subtract(double x, double y)
- {
- return x - y;
- }
-
- public double multiply(double x, double y)
- {
- return x * y;
- }
-
- public double divide(double x, double y)
- {
- if (y == 0)
- {
- System.out.println("Invalid input");
- return 0;
- }
- return x / y;
- }
-
- public double sqrt(double x)
- {
- return Math.sqrt(x);
- }
-
- public double exponent(double x, double y)
- {
- return Math.pow(x, y);
- }
-
- public double inverse(double x)
- {
- if (x ==0){
- return 0;
- }
- return 1 / x;
- }
- }
-
|