-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodingChallenge1.js
More file actions
50 lines (49 loc) · 1.59 KB
/
codingChallenge1.js
File metadata and controls
50 lines (49 loc) · 1.59 KB
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
let marksHgt = 1.88;
let markWgt = 95;
let johnHgt = 1.76;
let johnWgt = 85;
let johnBMI = johnWgt/(johnHgt**2);
let markBMI = markWgt/(marksHgt**2);
let markHigherBMI = markBMI>johnBMI;
if(markHigherBMI)
{
console.log(`Mark has Higher BMI than john ${johnBMI},${markBMI}`);
}
else
{
console.log(`Mark has lower BMI than John ${johnBMI},${markBMI}👍`);
}
/*let dolphinsScore1 = Number(prompt("Input your score1: "));
let dolphinsScore2 = Number(prompt("Input your score2: "));
let dolphinsScore3 = Number(prompt("Input your score3: "));
let dolphinAvg = (dolphinsScore1+dolphinsScore2+dolphinsScore3)/3;
let koalasScore1 = Number(prompt("Input Koalas score1: "));
let koalasScore2 = Number(prompt("Input Koalas score2: "));
let koalasScore3 = Number(prompt("Input Koalas score3: "));
let koalasAvg = (koalasScore1+koalasScore2+koalasScore3)/3;
if((dolphinAvg === koalasAvg) && (dolphinAvg>=100))
{
console.log("Both the scores are equal");
}
else if((dolphinAvg>koalasAvg) &&(dolphinAvg>=100))
{
console.log("Dolphins Average is greater than Koalas Average");
}
else if((koalasAvg>dolphinAvg) && (koalasAvg>=100))
{
console.log("Dolphins Average is greater than Koalas Average");
}
*/
let bill = Number(prompt("enter the Bill amount: "));
let tip;
((bill>=50) && (bill<=300))?x=1:x=0;
switch (x) {
case 1:
tip = bill*(0.15);
console.log(`The bill amount is ${bill} and the tip is ${tip} and total=${tip+bill}`);
break;
default:
tip = bill*(0.2);
console.log(`The bill amount is ${bill} and the tip is ${tip} and total=${tip+bill}`);
break;
}