Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8fc64b4

Browse files
committed
[Veer] Added : Problems on If elseif else
1 parent bbb089f commit 8fc64b4

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

‎If-ElseIf-Else/elseifProblems.js

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
const prompt = require("prompt-sync")();
2+
3+
//1.number to words
4+
let number = prompt("Enter a single Digit Number : ")
5+
if(number == 1){
6+
console.log("One")
7+
}
8+
else if(number == 2){
9+
console.log("Two")
10+
}
11+
else if(number == 3){
12+
console.log("Three")
13+
}
14+
else if(number == 4){
15+
console.log("Four")
16+
}
17+
else if(number == 5){
18+
console.log("Five")
19+
}
20+
else if(number == 6){
21+
console.log("Six")
22+
}
23+
else if(number == 7){
24+
console.log("Seven")
25+
}
26+
else if(number == 8){
27+
console.log("Eight")
28+
}
29+
else if(number == 9){
30+
console.log("Nine")
31+
}
32+
else{
33+
console.log("Number is not a Single Digit Number")
34+
}
35+
36+
console.log("=============================================")
37+
38+
//2.Read Number and display week
39+
40+
let weekDay = parseInt(prompt("Enter a week day : "))
41+
if(weekDay == 1){
42+
console.log("Sunday")
43+
}
44+
else if(weekDay == 2){
45+
console.log("Monday")
46+
}
47+
else if(weekDay == 3){
48+
console.log("Tuesday")
49+
}
50+
else if(weekDay == 4){
51+
console.log("Wednesday")
52+
}
53+
else if(weekDay == 5){
54+
console.log("Thursday")
55+
}
56+
else if(weekDay == 6){
57+
console.log("Friday")
58+
}
59+
else if(weekDay == 7){
60+
console.log("Saturday")
61+
}
62+
63+
console.log("=============================================")
64+
65+
//3.Read Number and show Units
66+
67+
let num = parseInt(prompt("Enter Number btw 1,10,100,1000,10000: "))
68+
if(num == 1){
69+
console.log("unit")
70+
}
71+
else if(num == 10){
72+
console.log("tens")
73+
}
74+
else if(num == 100){
75+
console.log("hundreds")
76+
}
77+
else if(num == 1000){
78+
console.log("thousands")
79+
}
80+
else if(num == 10000){
81+
console.log("ten thousands")
82+
}
83+
console.log("=============================================")
84+
85+
//4.arithmetic operations
86+
87+
let a,b,c
88+
a= prompt("Enter A :")
89+
b= prompt("Enter B :")
90+
c= prompt("Enter C :")
91+
92+
max = a + b * c
93+
min = a + b * c
94+
95+
if(a % b + c > max){
96+
max = a % b + c
97+
console.log("The min is a % b + c ",a % b + c)
98+
}
99+
else if(c + a / b > max){
100+
max = c + a / b
101+
console.log("The min is c + a / b ",c + a / b)
102+
}
103+
else if(a* b + c > max){
104+
max = a* b + c
105+
console.log("The min is a* b + c ",a* b + c)
106+
}
107+
else if(a % b + c < min){
108+
min = a % b + c
109+
console.log("The max is a % b + c ",a % b + c)
110+
}
111+
else if(c + a / b < min){
112+
min = c + a / b
113+
console.log("The max is c + a / b ",c + a / b)
114+
}
115+
else if(a* b + c < min){
116+
min = a* b + c
117+
console.log("The max is a* b + c ",a* b + c)
118+
}
119+
if(a + b * c == min){
120+
console.log("The max is a + b * c ",a + b * c)
121+
}
122+
else{
123+
console.log(" The min is a + b * c",a + b * c)
124+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /