Browse Source

HW<03> done

GennadyBerg 2 years ago
parent
commit
1f60b0ad4b
5 changed files with 61 additions and 0 deletions
  1. 12 0
      js/03/home03.html
  2. 9 0
      js/03/home03_003.html
  3. 11 0
      js/03/home03_04.html
  4. 12 0
      js/03/home03_05.html
  5. 17 0
      js/03/home03_1.html

+ 12 - 0
js/03/home03.html

@@ -0,0 +1,12 @@
+<head></head>
+
+<body>
+    <script>
+        let age = +prompt("Enter please Your age");
+        var date = new Date();
+        let curYear = date.getFullYear();
+        let birthDay = curYear - age;
+        alert(" You was born " + birthDay);
+    </script>
+
+</body>

+ 9 - 0
js/03/home03_003.html

@@ -0,0 +1,9 @@
+<head></head>
+
+<body>
+    <script>
+        const rate = 1.5;
+        let money1 = +prompt("Enter money");
+        alert("Yours money cost: " + (money1 * rate).toFixed(2));
+    </script>
+</body>

+ 11 - 0
js/03/home03_04.html

@@ -0,0 +1,11 @@
+<head></head>
+
+<body>
+    <script>
+        let red = +prompt("Enter red");
+        let green = +prompt("Enter green");
+        let blue = +prompt("Enter blue");
+        let color = blue + green*256 + red*256*256;
+        alert("COLOR: #" + color.toString(16).toUpperCase().padStart(6, '0'));
+    </script>
+</body>

+ 12 - 0
js/03/home03_05.html

@@ -0,0 +1,12 @@
+<head></head>
+
+<body>
+    <script>
+        const floors = 9;
+        const flats = 4;
+        let flatNum = +prompt("Enter flat number");
+        let entrance = Math.floor(flatNum / flats / floors);
+        let floor = Math.floor((flatNum - (entrance * 36)) / flats);
+        alert("Entrance: " + (entrance + 1) + ", Floor: " + (floor+1));
+    </script>
+</body>

+ 17 - 0
js/03/home03_1.html

@@ -0,0 +1,17 @@
+<head></head>
+
+<body>
+    <script>
+        let temperStr = prompt("Enter please temperature with F or C ");
+        temperVal = temperStr.substring(0, temperStr.length - 1);
+        if (temperStr.charAt(temperStr.length - 1) == 'F') {
+            let temperCels = (temperVal - 32.0) * 5.0 / 9.0;
+            alert("Temperature in Celsius: " + temperCels.toFixed(1) + "C");
+        }
+        else {
+            let temperFahr = (temperVal * 9.0 / 5.0) + 32.0;
+            alert("Temperature in Fahrengeit: " + temperFahr.toFixed(1) + "F");
+        }
+    </script>
+
+</body>