• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Feb 27th, 2020 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1.
2. //// Exercise 1
3. {
4.     let a = 20;
5.     let b = 15;
6.     if ( a > b){
7.         console.log("Max is a " + a );
8.     }
9.     else{
10.         console.log("Max is b " + b );
11.
12.     }
13. }
14.
15. //// Exercise 2
16. {
17.     let year = 2020;
18.     if (( year % 4 == 0 && year % 100 != 0 && year % 400 == 0 )){
19.         console.log(`\${year} is leap year`);
20.     }
21.     else{
22.         console.log(`\${year} is leap year`);
23.     }
24. }
25.
26. ///// Exercise 3
27. {
28. let a = 1, b = 3, c = 2;
29. //// ax^2 + bx + c = 0
30. let d = b * b - (4 * a * c);
31. if (d > 0){
32.     let answ1 = ((-1*b) + (Math.sqrt(d))) / (2*a);
33.     let answ2 = ((-1*b) - (Math.sqrt(d))) / (2*a);
35. }else if ( d === 0){
36.     let answ = ( -1 * b) / (2 * a);
37. }else {
38.     console.log("No solution");
39. }
40.
41. }
42.
43. //// Exercise 4
44. {
45. let a = 4, b = 5, c = 7;
46. if ( a > b && a > c){
47.     console.log(`Maximum between a, b, c is \${a}`);
48. }else if ( b > a && b > c){
49.     console.log(`Maximum between a, b, c is \${b}`);
50. }else{
51.     console.log(`Maximum between a, b, c is \${c}`);
52. }
53. }
54.
55. //// Exercise 5
56. {
57.     let x = -1, y = 2;
58.     if ( 3 * x + y * 2 + 1 == 0 ){
59.         console.log("YES");
60.     }else{
61.         console.log("NO");
62.     }
63. }
64.
65. //// Exercise 6
66. {
67.     let a = 4, b = 3, c = 8;
68.     if ( a + b > c && b + c > a && a + c > b){
69.      console.log("YES");
70.     }else("NO");
71.     console.log("NO");
72.
73. }
74. ///// Home work
75. {
76.     let purchase1 = 500, purchase2 = 60000, purchase3 = 2500;
77.     let sum = purchase1 + purchase2 + purchase3;
78.     let cashback;
79.     if ( sum <= 1000 ){
80.         cashback = sum * 15 / 100;
81.     }else if ( sum <= 3000){
82.         cashback = sum * 10 / 100;
83.     }else ( cashback = sum * 15 / 100);
84.     if ( cashback <= 3000){