diff --git a/calc/images/bg.jpg b/calc/images/bg.jpg new file mode 100644 index 0000000..78e9c65 Binary files /dev/null and b/calc/images/bg.jpg differ diff --git a/calc/index.html b/calc/index.html new file mode 100644 index 0000000..a510bc8 --- /dev/null +++ b/calc/index.html @@ -0,0 +1,29 @@ + + + + + + calculator + + + + +
+

Basic calculator

+ + + + +
+ + + +
+ +

Result:

+ + + + + \ No newline at end of file diff --git a/calc/script.js b/calc/script.js new file mode 100644 index 0000000..36dfbcf --- /dev/null +++ b/calc/script.js @@ -0,0 +1,42 @@ +function addNumbers() { + + var num1 = parseFloat(document.getElementById("num1").value); + var num2 = parseFloat(document.getElementById("num2").value); + + // Check if the input is a valid number + if (isNaN(num1) || isNaN(num2)) { + alert("Please enter valid numbers"); + return; + } + + // Calculate + var result = num1 + num2; + document.getElementById("result").textContent = result; + + // Change the color of the button to green + var calculateButton = document.getElementById("calculateButton"); + calculateButton.style.backgroundColor = "green"; + + + displayGreeting(); +} + +function displayGreeting() { + + var currentTime = new Date(); + var currentHour = currentTime.getHours(); + + var greetingMessage = ""; + + if (currentHour < 12) { + greetingMessage = "Good morning!"; + } else if (currentHour < 18) { + greetingMessage = "Good afternoon!"; + } else if (currentHour < 20){ + greetingMessage = "Good evening!"; + } else{ + greetingMessage = "Good night!"; + } + + alert(greetingMessage); +} \ No newline at end of file diff --git a/calc/style.css b/calc/style.css new file mode 100644 index 0000000..f6fd1d8 --- /dev/null +++ b/calc/style.css @@ -0,0 +1,38 @@ +*{ + margin: 0; + padding: 0; + font-family: 'poppins', sans-serif; + box-sizing: border-box; +} + +body { + font-family: Arial, sans-serif; + text-align: center; + display: flex; + align-items: center; + justify-content: center; + width: 100%; + height: 100vh; + background-image: linear-gradient(rgba(34, 24, 105, 0.65), rgba(7, 2, 46, 0.65)), url(images/bg.jpg); + background-size: cover; + background-position: center; + padding: 30px; + padding-left: 8%; + padding-right: 8%; + box-sizing: border-box; +} + +#calculatorContainer { + border: 1px solid #150202; + padding: 20px; + border-radius: 8px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.36); + background-color: rgb(21, 8, 54); + color: whitesmoke; +} +input, button { + font-size: 16px; + margin: 5px; + padding: 10px; + +} \ No newline at end of file