Created
August 15, 2014 00:01
-
-
Save AliZafar120/cfdc1b2bef5607913e28 to your computer and use it in GitHub Desktop.
BasicCalculator class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package edu.univdhaka.iit.calculator; | |
import java.math.BigInteger; | |
public class BasicCalculator { | |
public BigInteger add(BigInteger a,BigInteger b) | |
{ | |
return a.add(b); | |
} | |
public BigInteger subtract(BigInteger a,BigInteger b) | |
{ | |
if (b.compareTo(a)==-1) return a.subtract(b); | |
else if (a.compareTo(b)==-1) return b.subtract(a); | |
else return a.subtract(b) ; | |
} | |
public BigInteger multiply(BigInteger a,BigInteger b) | |
{ | |
return a.multiply(b); | |
} | |
public BigInteger divide(BigInteger a,BigInteger b) | |
{ | |
//BigInteger result = new BigInteger(a.doubleValue()); | |
return a.divide(b); | |
} | |
public BigInteger exponent(BigInteger a,int b) | |
{ | |
return a.pow(b); | |
} | |
public double squareroot(double a) | |
{ | |
return Math.sqrt(a); | |
} | |
public int percentage(int a,int b) | |
{ | |
return a*b/100; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment