/** * A class to define math opeerations for the * Calculator */ import java.lang.Math; public class BasicCalculations extends Operations { private int x; /** * Constructor for objects of class BasicCalculations */ public BasicCalculations() { // initialise instance variables x = 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 sampleMethod(double y) { // put your code here return x + y; } public void add(double x, double y) { double z = x + y; update(z); } public double subtract(double x, double y) { double z = x - y; update(z); return z; } public double multiply(double x, double y) { double z = x * y; update(z); return z; } public void divide(double x, double y) { if (y == 0){ System.out.println("Error"); isError = true; } else { double z = (x / y); update(z); } } public void square(double x){ double z = x * x; update(z); } public void squareRoot (double x){ double z = Math.sqrt(x); update(z); } public void power(double x,double y){ double z = Math.pow(x,y); update(z); } public void sin(double x){ double z = Math.sin(x); update(z); } public void cos(double x){ double z = Math.cos(x); update(z); } public void tan(double x){ double z = Math.tan(x); update(z); } public void degrees(double x){ double z = Math.toDegrees(x); update(z); } public void radians(double x){ double z = Math.toRadians(x); update(z); } public void atan(double x){ double z = Math.atan(x); update(z); } public void acos(double x){ double z = Math.acos(x); update(z); } public void asin(double x){ double z = Math.asin(x); update(z); } public void log(double x){ double z = Math.log10(x); update(z); } public void round(double x) { double z = Math.round(x); update(z); } public void roundUp(double x) { double z = Math.ceil(x); update(z); } public void roundDown(double x) { double z = Math.floor(x); update(z); } public void inverse(double x) { double z = (1/x); update(z); } }