repl.it
@PacoTaco/

Calculator

Nodejs

No description

fork
loading
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 class Calculator {
  constructor() {

  }

  add(a, b) {
    return a + b
  }
  sub(a, b) {
    return a - b
  }
  divide(a, b) {
    return a / b
  }
  multiply(a, b) {
    return a * b
  }
  rectArea(l, w) {
    return l * w
  }
  rectPerm(l, w) {
    return 2 * l + 2 * w
  }
  triArea(h, b) {
    return h * b / 2
  }
  triPerm(a, b, c) {
    return a + b + c
  }
  circleArea(r) {
    return Math.PI * r * r
  }
  circleCirc(r) {
    return 2 * Math.PI * r
  }
  hypotenuse(a, b) {
    return Math.sqrt(a * a + b * b)
  }
  distance(x1,y1,x2,y2){
    var a = x1 - x2
    var b = y1 - y2
    return this.hypotenuse(a,b)
  }
  volume(w,h,l){
    return w*h*l
  }
  volumeSphere(r){
    return 4/3*Math.PI*r*r*r
  }
  volumeCylinder(r,h){
    return Math.PI*r*r*h
  }
  volumeCone(r,h){
    return Math.PI*r*r*h/3
  }
  listSum(arr){
    var total = 0
    for(var i = 0; i<arr.length ;i++){
      total = arr[i] + total
    }
    return total
  }
}

var calc = new Calculator()
Fetching token
?