-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2beec15
commit 86a6c8c
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); |