-
Notifications
You must be signed in to change notification settings - Fork 0
/
cal01.ts
46 lines (41 loc) · 1.07 KB
/
cal01.ts
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
#!/usr/bin/env node
console.log("Welcome")
import inquirer from "inquirer"
import { plus01 } from "./oerators/add.js"
import { minus01 } from "./oerators/sub.js"
import { multiple01 } from "./oerators/multi.js"
import { divide01 } from "./oerators/div.js"
let answer = await inquirer.prompt ([
{
message: "Enter Your First Nummber",
type: "number",
name: "num1"
},
{
message: "Enter Your Second Nummber",
type: "number",
name: "num2"
},
{
message: "Select Operator",
type: "list",
choices: ["+","-","*","/"],
name: "operator"
},
])
if (answer.operator === "+"){
let result= plus01(answer.num1, answer.num2);
console.log(result);
}
else if( answer.operator === "-"){
let result= minus01( answer.num1, answer.num2);
console.log(result);
}
else if( answer.operator === "*"){
let result= multiple01( answer.num1, answer.num2);
console.log(result);
}
else if( answer.operator === "/"){
let result= divide01( answer.num1, answer.num2);
console.log(result);
}