/cop4808-git-and-github-fundamentals-jkantlehner2018

cop4808-git-and-github-fundamentals-jkantlehner2018 created by GitHub Classroom

Primary LanguageHTML

John Kantlehner Z23474365


Using https://github.com/mrbuddh4/calculator as the base calculator, 4 new buttons have been implemented

calculator gif


Buttons Added

Button Description
ex operation
√ (sqrt) operation
π operand
xy operation

  • Handling for New Buttons

            else if(buttons[i].classList.contains('e')) {
                  inputE(displayValue);
                  updateDisplay();
            }
            else if(buttons[i].classList.contains('sqrt')) {
                  inputSqrt(displayValue);
                  updateDisplay();
            }
            else if(buttons[i].classList.contains('pi')) {
                  inputOperand(Math.PI.toFixed(9));
                  updateDisplay();

            }
            else if(buttons[i].classList.contains('exponent')) {
                  inputOperator(buttons[i].value);
            }
  • Functions added for single operand operations

            function inputE(num) {
                displayValue = Math.exp(num).toString();
            }

            function inputSqrt(num) {
                displayValue = Math.sqrt(num).toString();
            }
  • Exponent operation added in operate function

        
            else if(op === 'exponent'){
                return Math.pow(x,y);
            }