Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lesson 06-expression-calculator-for-kimberlee #247

Closed
wants to merge 11 commits into from
24 changes: 21 additions & 3 deletions lesson_06/expression/src/expression_calculator.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
export class ExpressionCalculator {
/** Returns the calculation of ((a + b) * c) / d^e */
calculate(a: number, b: number, c: number, d: number, e: number): number {
// Implement your code here to return the correct value.
return 0;
const P = this.add(a, b);
haldanek marked this conversation as resolved.
Show resolved Hide resolved
const E = this.pow(d, e);
const M = this.multiply(P, c);
const D = this.divide(M, E);
return D;
//const expression = this.mult(this.add(a, b), c) / this.pow(d, e);
//return expression;
}

pow(base: number, exponent: number): number {
return Math.pow(base, exponent);
const expo = Math.pow(base, exponent);
return expo;
}
add(x: number, y: number): number {
const addition = x + y;
return addition;
}
multiply(X: number, Y: number): number {
const multiply = X * Y;
return multiply;
}
divide(x: number, y: number): number {
const divide = x / y;
return divide;
}
}