diff --git a/Calculators/Sound-Level-Calculator/README.md b/Calculators/Sound-Level-Calculator/README.md new file mode 100644 index 000000000..9e90a8edc --- /dev/null +++ b/Calculators/Sound-Level-Calculator/README.md @@ -0,0 +1,13 @@ +#

Sound Level Calculator

+ +A simple web-based sound level calculator that allows users to input two sound levels in decibels (dB) and calculate the combined sound level. + +## Tech Stacks :- + +- HTML +- CSS +- JavaScript + +## Screenshots :- + +![image](https://github.com/Rakesh9100/CalcDiverse/assets/73993775/ea90d4e9-8e3a-40f1-9949-f7134d663506) diff --git a/Calculators/Sound-Level-Calculator/index.html b/Calculators/Sound-Level-Calculator/index.html new file mode 100644 index 000000000..b34b4b040 --- /dev/null +++ b/Calculators/Sound-Level-Calculator/index.html @@ -0,0 +1,29 @@ + + + + + + + Sound Level Calculator + + +
+

Sound Level Calculator

+
+
+ + +
+
+ + +
+ +
+
+

Combined Sound Level: 0 dB

+
+
+ + + diff --git a/Calculators/Sound-Level-Calculator/script.js b/Calculators/Sound-Level-Calculator/script.js new file mode 100644 index 000000000..dc1a35ff1 --- /dev/null +++ b/Calculators/Sound-Level-Calculator/script.js @@ -0,0 +1,22 @@ +document.getElementById('soundForm').addEventListener('submit', function(event) { + event.preventDefault(); + + const sound1 = parseFloat(document.getElementById('sound1').value); + const sound2 = parseFloat(document.getElementById('sound2').value); + + if (isNaN(sound1) || isNaN(sound2)) { + alert('Please enter valid numbers for both sound levels.'); + return; + } + + const combinedSoundLevel = calculateCombinedSoundLevel(sound1, sound2); + document.getElementById('result').textContent = combinedSoundLevel.toFixed(2); +}); + +function calculateCombinedSoundLevel(sound1, sound2) { + const power1 = Math.pow(10, sound1 / 10); + const power2 = Math.pow(10, sound2 / 10); + const combinedPower = power1 + power2; + const combinedSoundLevel = 10 * Math.log10(combinedPower); + return combinedSoundLevel; +} diff --git a/Calculators/Sound-Level-Calculator/style.css b/Calculators/Sound-Level-Calculator/style.css new file mode 100644 index 000000000..d0cfa78aa --- /dev/null +++ b/Calculators/Sound-Level-Calculator/style.css @@ -0,0 +1,59 @@ +body { + font-family: Arial, sans-serif; + background-color: #f4f4f4; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + margin: 0; +} + +.container { + background: #fff; + padding: 20px; + border-radius: 10px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + text-align: center; +} + +h1 { + margin-bottom: 20px; +} + +.input-group { + margin-bottom: 15px; +} + +.input-group label { + display: block; + margin-bottom: 5px; +} + +.input-group input { + width: 100%; + padding: 10px; + border: 1px solid #ccc; + border-radius: 5px; +} + +button { + padding: 10px 20px; + border: none; + border-radius: 5px; + background-color: #5cb85c; + color: #fff; + cursor: pointer; + font-size: 16px; +} + +button:hover { + background-color: #4cae4c; +} + +.result { + margin-top: 20px; +} + +.result h2 { + font-size: 24px; +} diff --git a/index.html b/index.html index f6f376fb8..2f85553c0 100644 --- a/index.html +++ b/index.html @@ -3366,6 +3366,20 @@

Calculates the amount one can save on electricity by installing solar panels +
+
+

Sound Level Calculator

+

Calculator to combine two sound levels in decibels (dB).

+ +
+

Speed Calculator