123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
-
- public class Calculator
- {
- // instance variables - replace the example below with your own
- private double displayValue;
- private double memoryValue;
- <<<<<<< HEAD
-
- //private CoreFeatures core;
- //private ScientificFeatures science;
- //private BonusFeatures bonus;
- =======
- private boolean err;
- >>>>>>> 85cb6e118e199051f7fc22d59044b58cdf7dcf01
-
- /**
- * Constructor for objects of class Calculator
- */
- public Calculator()
- {
- displayValue = 0;
- memoryValue = 0;
- err = false;
- }
-
- //Memory set
- public double memSet(){
- memoryValue = displayValue;
- return memoryValue;
- }
-
- public double memClear(){
- memoryValue = 0;
- return memoryValue;
- }
-
- public double mrc(){
- displayValue = memoryValue;
- return displayValue;
- }
-
- //Clear and retrieve display value
- public double clear(){
- displayValue = 0;
- err = false;
- return displayValue;
- }
-
- public double getDisplayValue(){
- return displayValue;
- }
-
- //basic functions
- public double add(double value1, double value2){
- displayValue = value1 + value2;
- return displayValue;
- }
-
- public double subtract(double value1, double value2){
- displayValue = value1 - value2;
- return displayValue;
- }
-
- public double multiply(double value1, double value2){
- displayValue = value1 * value2;
- return displayValue;
- }
-
- public double divide(double dividend, double divisor){
- displayValue = dividend / divisor;
- return displayValue;
- }
-
- public double pow(double base, double exponent){
- displayValue = Math.pow(base, exponent);
- return displayValue;
- }
-
- public double square(double base){
- return pow(base, 2);
- }
-
- public double squareRoot(double value){
- displayValue = Math.sqrt(value);
- return displayValue;
- }
-
- public double inverse(double value){
- displayValue = 1 / value;
- return displayValue;
- }
-
- public double changeSign(double value){
- return multiply(value, -1);
- }
-
- //scientific functions
- public double sin(double value){
- displayValue = Math.sin(value);
- return displayValue;
- }
-
- public double cos(double value) {
- displayValue = Math.cos(value);
- return displayValue;
- }
-
- public double tan(double value) {
- displayValue = Math.tan(value);
- return displayValue;
- }
-
- public double log(double value) {
- displayValue = Math.log(value);
- return displayValue;
- }
-
- public double inverseSin(double value) {
- displayValue = Math.log(value);
- return displayValue;
- }
-
- public double inverseCos(double value) {
- displayValue = Math.acos(value);
- return displayValue;
- }
-
- public double inverseTan(double value) {
- displayValue = Math.atan(value);
- return displayValue;
- }
-
- public double inverseLog(double value){
- displayValue = Math.pow(value, 10);
- return displayValue;
- }
-
- public double naturalLog(double value) {
- displayValue = Math.log1p(value);
- return displayValue;
- }
-
- public double inverseLn(double value) {
- displayValue = Math.pow(Math.E, value);
- return displayValue;
- }
-
- public double displayPi() {
- displayValue = Math.PI;
- return displayValue;
- }
-
- public double displayE(){
- displayValue = Math.E;
- return Math.E;
- }
-
- }
|