-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
260 lines (143 loc) · 4.37 KB
/
index.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
console.log("Question No =1");
let tempInCelsius: number = 23;
// to convert the temperature from celsius to fahrenheit
// formula for celsius to fahrenheit
// F=9/5(C) +32
let fahrenheit: number = 9 / 5 * (tempInCelsius) + 32;
console.log(`fahrenheit ${fahrenheit}`);
// to convert the temperature from fahrenheit
// formula for fahrenheit to celsius
// C=5/9(F-32)
let tempInFahrenheit: number = 67;
let celsius: number = 5 / 9 * (tempInFahrenheit - 32);
console.log(`celsius ${celsius}`);
console.log("Question No -2");
// to find the percentage of a number
let value: number = 8;
let totalNumber: number = 16;
let percentage: number = value / totalNumber * 100;
console.log(percentage);
console.log("Question No-3");
// no of days into weeks and days
let givenDay: number = 30;
let weeks: number = givenDay / 7;
let remainder: number = givenDay % 7;
let newGivenDay = (Math.floor(weeks));
console.log(`week=${newGivenDay}`);
console.log(`days=${remainder}`);
console.log("Question No-4");
// let priceUnit:string="$";
let price: number = 50;
if (price > 100) {
let discount: number = (price / 100) * 10;
let DiscountPrice: number = price - discount;
console.log(`After Discount ${DiscountPrice}$`);
}
else {
let discount: number = (price / 100) * 5;
let DiscountPrice: number = price - discount;
console.log(`After Discount ${DiscountPrice}$`);
}
console.log("Question No -5");
let age: number = 19;
if (age >= 0 && age <= 13) {
console.log(`Child age is ${age}`);
}
else if (age >= 13 && age <= 19) {
console.log(`Teenager age is ${age}`);
}
else {
console.log(`Adult age is ${age}`);
}
console.log("Question No -6");
let temperatureMeasuresIn: string = "Celsius";
let temperature: number = -2;
if (temperature <= 18 && temperature >= -2) {
console.log("it is good to wear sweater");
}
else {
console.log("it is advised to wear cloth according to their choice");
}
console.log("Question No -7");
// to check out the numbeer is divided by 3 and 5 or both
let givenNumber: number = 9
let divided1: number = givenNumber / 3
let divided2: number = givenNumber / 5
console.log(divided1);
console.log(divided2);
if (divided1 != 0) {
console.log("is divisible");
}
else {
console.log("does not divisible");
}
if (divided2 != 0) {
console.log("is divisible");
}
else {
console.log("does not divisible");
}
if (divided1 != 0 && divided2 != 0) {
console.log("yes both is divisible");
}
else {
console.log(" both does not divisible");
}
console.log("Question No -8");
let year: number = 2028;
//leapYears of half centuary=2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, 2044, and 2048
let divide: number = year % 4
console.log(divide)
// we check out the loop year by dividing by 4, if answer is zero(0), then it is loop year.
if (divide == 0) {
console.log("yes it is loop year");
}
else {
console.log("it is not loop year");
}
console.log("Question No -9")
let givenNumbers: number = 7
if (givenNumbers == 1) {
console.log("The day is monday");
}
else if (givenNumbers == 2) {
console.log("The day is tuesday");
}
else if (givenNumbers == 3) {
console.log("The day is wednesday");
}
else if (givenNumbers == 4) {
console.log("The day is thursday");
}
else if (givenNumbers == 5) {
console.log("The day is friday");
}
else if (givenNumbers == 6) {
console.log("The day is saturday");
}
else if (givenNumbers == 7) {
console.log("The day is sunday");
}
else {
console.log("Invalid number please try again");
}
console.log("Question No -10");
let units: number = 550;
if (units > 100 && units < 200) {
let tax: number = (10 / 100) * units
let bill: number = tax + units
console.log(`newBill ${bill}`);
}
else if (units > 200 && units < 500) {
let tax: number = (15 / 100) * units
let bill: number = tax + units
console.log(`newBill ${bill}`);
}
else if (units > 500) {
let tax: number = (25 / 100) * units
let bill: number = tax + units
console.log(`newBill ${bill}`);
}
else {
console.log(`"there is no tax" bill is${units}`);
}