diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a881469 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures diff --git a/ScientificCalculator/.idea/.name b/ScientificCalculator/.idea/.name new file mode 100644 index 0000000..883c721 --- /dev/null +++ b/ScientificCalculator/.idea/.name @@ -0,0 +1 @@ +ScientificCalculator \ No newline at end of file diff --git a/ScientificCalculator/.idea/compiler.xml b/ScientificCalculator/.idea/compiler.xml new file mode 100644 index 0000000..217af47 --- /dev/null +++ b/ScientificCalculator/.idea/compiler.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/ScientificCalculator/.idea/copyright/profiles_settings.xml b/ScientificCalculator/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/ScientificCalculator/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ScientificCalculator/.idea/encodings.xml b/ScientificCalculator/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/ScientificCalculator/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/ScientificCalculator/.idea/gradle.xml b/ScientificCalculator/.idea/gradle.xml new file mode 100644 index 0000000..736c7b5 --- /dev/null +++ b/ScientificCalculator/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/ScientificCalculator/.idea/libraries/appcompat_v7_22_1_1.xml b/ScientificCalculator/.idea/libraries/appcompat_v7_22_1_1.xml new file mode 100644 index 0000000..5c93ee4 --- /dev/null +++ b/ScientificCalculator/.idea/libraries/appcompat_v7_22_1_1.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ScientificCalculator/.idea/libraries/arity_2_1_7.xml b/ScientificCalculator/.idea/libraries/arity_2_1_7.xml new file mode 100644 index 0000000..df817a3 --- /dev/null +++ b/ScientificCalculator/.idea/libraries/arity_2_1_7.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ScientificCalculator/.idea/libraries/javaluator_3_0_0.xml b/ScientificCalculator/.idea/libraries/javaluator_3_0_0.xml new file mode 100644 index 0000000..ffa12cd --- /dev/null +++ b/ScientificCalculator/.idea/libraries/javaluator_3_0_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ScientificCalculator/.idea/libraries/support_annotations_22_1_1.xml b/ScientificCalculator/.idea/libraries/support_annotations_22_1_1.xml new file mode 100644 index 0000000..ef92029 --- /dev/null +++ b/ScientificCalculator/.idea/libraries/support_annotations_22_1_1.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ScientificCalculator/.idea/libraries/support_v4_22_1_1.xml b/ScientificCalculator/.idea/libraries/support_v4_22_1_1.xml new file mode 100644 index 0000000..8532152 --- /dev/null +++ b/ScientificCalculator/.idea/libraries/support_v4_22_1_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/ScientificCalculator/.idea/misc.xml b/ScientificCalculator/.idea/misc.xml new file mode 100644 index 0000000..2991b9f --- /dev/null +++ b/ScientificCalculator/.idea/misc.xml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost + 5050 + + + + diff --git a/ScientificCalculator/.idea/modules.xml b/ScientificCalculator/.idea/modules.xml new file mode 100644 index 0000000..e35acaf --- /dev/null +++ b/ScientificCalculator/.idea/modules.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/ScientificCalculator/.idea/scopes/scope_settings.xml b/ScientificCalculator/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/ScientificCalculator/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/ScientificCalculator/.idea/vcs.xml b/ScientificCalculator/.idea/vcs.xml new file mode 100644 index 0000000..275077f --- /dev/null +++ b/ScientificCalculator/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ScientificCalculator/.idea/workspace.xml b/ScientificCalculator/.idea/workspace.xml new file mode 100644 index 0000000..aaa6c71 --- /dev/null +++ b/ScientificCalculator/.idea/workspace.xml @@ -0,0 +1,2138 @@ + + + + + + + + + + + + android-19 + + + + + + @style/AppTheme + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost + 5050 + + + + + + + + + + 1430870077108 + 1430870077108 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ScientificCalculator/README.md b/ScientificCalculator/README.md new file mode 100644 index 0000000..66a5cd2 --- /dev/null +++ b/ScientificCalculator/README.md @@ -0,0 +1 @@ +Scientific Calculator App diff --git a/ScientificCalculator/ScientificCalculator.iml b/ScientificCalculator/ScientificCalculator.iml new file mode 100644 index 0000000..0bb6048 --- /dev/null +++ b/ScientificCalculator/ScientificCalculator.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + diff --git a/ScientificCalculator/ScientificCalculatorApp.iml b/ScientificCalculator/ScientificCalculatorApp.iml new file mode 100644 index 0000000..0bb6048 --- /dev/null +++ b/ScientificCalculator/ScientificCalculatorApp.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + diff --git a/ScientificCalculator/app/.gitignore b/ScientificCalculator/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/ScientificCalculator/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/ScientificCalculator/app/app.iml b/ScientificCalculator/app/app.iml new file mode 100644 index 0000000..bf6dbdc --- /dev/null +++ b/ScientificCalculator/app/app.iml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ScientificCalculator/app/build.gradle b/ScientificCalculator/app/build.gradle new file mode 100644 index 0000000..9fcb35e --- /dev/null +++ b/ScientificCalculator/app/build.gradle @@ -0,0 +1,26 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 22 + buildToolsVersion "22.0.1" + + defaultConfig { + applicationId "app.poojawins.c4q.nyc.scientificcalculator" + minSdkVersion 16 + targetSdkVersion 22 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:22.1.1' + compile 'com.fathzer:javaluator:3.0.0' +} diff --git a/ScientificCalculator/app/libs/arity-2.1.7.jar b/ScientificCalculator/app/libs/arity-2.1.7.jar new file mode 100755 index 0000000..aecda2e Binary files /dev/null and b/ScientificCalculator/app/libs/arity-2.1.7.jar differ diff --git a/ScientificCalculator/app/proguard-rules.pro b/ScientificCalculator/app/proguard-rules.pro new file mode 100644 index 0000000..567ea55 --- /dev/null +++ b/ScientificCalculator/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/pooja/Library/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/ScientificCalculator/app/src/androidTest/java/app/poojawins/c4q/nyc/scientificcalculator/ApplicationTest.java b/ScientificCalculator/app/src/androidTest/java/app/poojawins/c4q/nyc/scientificcalculator/ApplicationTest.java new file mode 100644 index 0000000..f111e16 --- /dev/null +++ b/ScientificCalculator/app/src/androidTest/java/app/poojawins/c4q/nyc/scientificcalculator/ApplicationTest.java @@ -0,0 +1,13 @@ +package app.poojawins.c4q.nyc.scientificcalculator; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/ScientificCalculator/app/src/main/AndroidManifest.xml b/ScientificCalculator/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..fa21d97 --- /dev/null +++ b/ScientificCalculator/app/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + diff --git a/ScientificCalculator/app/src/main/ic_cal_launcher-web.png b/ScientificCalculator/app/src/main/ic_cal_launcher-web.png new file mode 100644 index 0000000..57544fd Binary files /dev/null and b/ScientificCalculator/app/src/main/ic_cal_launcher-web.png differ diff --git a/ScientificCalculator/app/src/main/java/app/poojawins/c4q/nyc/scientificcalculator/ArityParser.java b/ScientificCalculator/app/src/main/java/app/poojawins/c4q/nyc/scientificcalculator/ArityParser.java new file mode 100644 index 0000000..56938d0 --- /dev/null +++ b/ScientificCalculator/app/src/main/java/app/poojawins/c4q/nyc/scientificcalculator/ArityParser.java @@ -0,0 +1,22 @@ +package app.poojawins.c4q.nyc.scientificcalculator; + +/** + * Created by pooja on 5/21/15. + */ + +import org.javia.arity.Symbols; +import org.javia.arity.SyntaxException; + +public class ArityParser implements Parser{ + + public String parse(String expression) { + try { + Symbols symbols = new Symbols(); + double result = symbols.eval(expression); + return "" + result; + } catch (SyntaxException ex) { + return "ERROR: " + ex.getMessage(); + } + } + +} diff --git a/ScientificCalculator/app/src/main/java/app/poojawins/c4q/nyc/scientificcalculator/JavaluatorParser.java b/ScientificCalculator/app/src/main/java/app/poojawins/c4q/nyc/scientificcalculator/JavaluatorParser.java new file mode 100644 index 0000000..0e10497 --- /dev/null +++ b/ScientificCalculator/app/src/main/java/app/poojawins/c4q/nyc/scientificcalculator/JavaluatorParser.java @@ -0,0 +1,21 @@ +package app.poojawins.c4q.nyc.scientificcalculator; + +/** + * Created by pooja on 5/21/15. + */ + +import com.fathzer.soft.javaluator.DoubleEvaluator; + +public class JavaluatorParser implements Parser { + + public String parse(String expression){ + try { + DoubleEvaluator evaluator = new DoubleEvaluator(); + Double result = evaluator.evaluate(expression); + return "" + result; + } catch (Exception ex) { + return "ERROR"; + } + } + +} diff --git a/ScientificCalculator/app/src/main/java/app/poojawins/c4q/nyc/scientificcalculator/MainActivity.java b/ScientificCalculator/app/src/main/java/app/poojawins/c4q/nyc/scientificcalculator/MainActivity.java new file mode 100644 index 0000000..68c18d8 --- /dev/null +++ b/ScientificCalculator/app/src/main/java/app/poojawins/c4q/nyc/scientificcalculator/MainActivity.java @@ -0,0 +1,351 @@ +package app.poojawins.c4q.nyc.scientificcalculator; + +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.widget.TextView; +import android.widget.Button; +import java.util.ArrayList; +import android.view.View; + + +public class MainActivity extends ActionBarActivity { + public String lastAnswer = ""; + public boolean justEvaluated = false; + + TextView displayText; + + Button acButton; + Button equalButton; + + Button percentButton; + Button factorialButton; + Button decimalButton; + + Button plusButton; + Button subtractButton; + Button multiplyButton; + Button divideButton; + + Button number9Button; + Button number8Button; + Button number7Button; + Button number6Button; + Button number5Button; + Button number4Button; + Button number3Button; + Button number2Button; + Button number1Button; + Button number0Button; + + // scientific calculator specific buttons + Button backspaceButton; + Button radButton; + Button degButton; + Button squareRootButton; + Button xyButton; // (x^y) + Button expButton; + Button lnButton; + Button eButton; + Button logButton; + Button reciprocalButton; + Button piButton; + Button sineButton; + Button cosineButton; + Button tangentButton; + Button openParenthesisButton; + Button closeParenthesisButton; + Button answerButton; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + displayText = (TextView) findViewById(R.id.displayText); + + acButton = (Button) findViewById(R.id.acButton); + equalButton = (Button) findViewById(R.id.equalButton); + + percentButton = (Button) findViewById(R.id.percentButton); + factorialButton = (Button) findViewById(R.id.factorialButton); + decimalButton = (Button) findViewById(R.id.decimalButton); + + plusButton = (Button) findViewById(R.id.plusButton); + subtractButton = (Button) findViewById(R.id.subtractButton); + multiplyButton = (Button) findViewById(R.id.multiplyButton); + divideButton = (Button) findViewById(R.id.divideButton); + + number9Button = (Button) findViewById(R.id.number9Button); + number8Button = (Button) findViewById(R.id.number8Button); + number7Button = (Button) findViewById(R.id.number7Button); + number6Button = (Button) findViewById(R.id.number6Button); + number5Button = (Button) findViewById(R.id.number5Button); + number4Button = (Button) findViewById(R.id.number4Button); + number3Button = (Button) findViewById(R.id.number3Button); + number2Button = (Button) findViewById(R.id.number2Button); + number1Button = (Button) findViewById(R.id.number1Button); + number0Button = (Button) findViewById(R.id.number0Button); + + // scientific calculator specific buttons + backspaceButton = (Button) findViewById(R.id.backspaceButton); + radButton = (Button) findViewById(R.id.radButton); + degButton = (Button) findViewById(R.id.degButton); + squareRootButton = (Button) findViewById(R.id.squareRootButton); + xyButton = (Button) findViewById(R.id.xyButton); // (x^y) + expButton = (Button) findViewById(R.id.expButton); + lnButton = (Button) findViewById(R.id.lnButton); + eButton = (Button) findViewById(R.id.eButton); + logButton = (Button) findViewById(R.id.logButton); + reciprocalButton = (Button) findViewById(R.id.reciprocalButton); + piButton = (Button) findViewById(R.id.piButton); + sineButton = (Button) findViewById(R.id.sineButton); + cosineButton = (Button) findViewById(R.id.cosineButton); + tangentButton = (Button) findViewById(R.id.tangentButton); + openParenthesisButton = (Button) findViewById(R.id.openParenthesisButton); + closeParenthesisButton = (Button) findViewById(R.id.closeParenthesisButton); + answerButton = (Button) findViewById(R.id.answerButton); + + ArrayList