Creating a calculator that can represent the answer in both decimal and fraction format.
Core system codes are at https://github.com/Jin4202/FractionCalculator/tree/master/app/src/main/java/com/calculator/fractioncalculator
Switching the answer type into decimal and fraction by pressing the [A/B] button
- Framework: Android Studio
- Language: Java
- Transforming the answer from decimal to fraction
Solution: Independently build the arithmetic operations and input parsers.
Ex. inputs: n1, n2
Addtion: (n1.numerator*n2.denominator + n2.numerator*n1.denominator) / (n1.denominator*n2.denominator) Minus: (n1.numerator*n2.denominator - n2.numerator*n1.denominator) / (n1.denominator*n2.denominator) Multiplication: (n1.numerator*n2.numerator) / (n1.denominator*n2.denominator) Division: (n1.numerator*n2.denominator) / (n1.denominator*n2.numerator)
- Calculating while leaving the mathematical constant in the expressions
Basic idea: Creating a map that contains infomation of powers of constants and their coefficients.
PI-e Map
a(i,j) = a * PIi * ej
Examples)
Addition/Minus
a(i,j) + b(i,j) = (a+b)(i,j)
Multiplication
a(i1,j1) x b(i2,j2) = (axb)(i1+i2,j1+j2)
Division
2a(i1,j) / 2(i2,j) = a(i1-i2,j)
Challenge
Only way of finding common polynominal factor seems to be trying every single formula. Therefore, I only implemented the factorization of 'single' constant {a(0,0)} and mathematical constants.
- Trigonometry
- Logarithm
- Root
- Degree/Radian
- Factoring polymoninal