Skip to content

Commit

Permalink
Added my problem and solution
Browse files Browse the repository at this point in the history
  • Loading branch information
AvidCoder101 committed Oct 9, 2024
1 parent 2beec15 commit 86a6c8c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Beginner Level πŸ“/Calculator/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Create a calculator in the language Typescript that includes the following calculations:

- Adding
- Subtracting
- Multiplying
- Dividing
- Squaring
- Cubing
- Find square root
- Find cube root
35 changes: 35 additions & 0 deletions Beginner Level πŸ“/Calculator/solution.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
class Calculator {
input: number;
constructor(input:number){
this.input = input;
}

addNumber(num:number){
return this.input + num;
}
subtractNumber(num:number){
return this.input - num;
}
multiplyNumber(num:number){
return this.input * num;
}
divideNumber(num:number){
return this.input / num;
}
squareNumber(){
return this.input * this.input;
}
cubeNumber(){
return this.input * this.input * this.input;
}
findSqRoot(){
return Math.sqrt(this.input);
}
findCubeRoot(){
return Math.cbrt(this.input);
}

}

let myCalc = new Calculator(125);
console.log(myCalc.findCubeRoot());

0 comments on commit 86a6c8c

Please sign in to comment.