diff --git a/Calculators/Weather-Calculator/README.md b/Calculators/Weather-Calculator/README.md new file mode 100644 index 000000000..781ab3ca3 --- /dev/null +++ b/Calculators/Weather-Calculator/README.md @@ -0,0 +1,17 @@ +#
Weather Calculator
+ +## Description :- + +Calculates wind chill factor, dew point, and heat index, displays human thermal comfort, and converts temperature. + +## Tech Stacks :- + +- HTML +- CSS +- JavaScript + +## Screenshots :- + +![image](https://github.com/Rakesh9100/CalcDiverse/assets/143149376/7a9b9357-d3c2-4289-9ac7-5e6f9f2c9106) + +![image2](https://github.com/Rakesh9100/CalcDiverse/assets/143149376/891c9458-9758-4d0f-b848-0c182be5d1b5) diff --git a/Calculators/Weather-Calculator/index.html b/Calculators/Weather-Calculator/index.html new file mode 100644 index 000000000..e090def89 --- /dev/null +++ b/Calculators/Weather-Calculator/index.html @@ -0,0 +1,28 @@ + + + + + + +Temperature Conversion: ${convertTemperature(temperature)} °F
+Wind Chill: ${findWindChill(temperature, windSpeed)} °C
+Dew Point: ${findDewPoint(temperature, humidity)} °C
+Heat Index: ${findHeatIndex(temperature, humidity)} °C
+Human Thermal Comfort: ${findHumanThermalComfort(temperature, humidity, windSpeed)}
+ `; + + document.getElementById('results').innerHTML = results; +}); + +function convertTemperature(celsius) { + + return (celsius * 9/5) + 32; +} + +function findWindChill(temperature, windSpeed) { + + if (temperature > 10 || windSpeed < 4.8) { + return "❌"; + } + return (13.12 + 0.6215 * temperature - 11.37 * Math.pow(windSpeed, 0.16) + 0.3965 * temperature * Math.pow(windSpeed, 0.16)).toFixed(2); +} + +function findDewPoint(temperature, humidity) { + + const a = 17.27; + const b = 237.7; + const alpha = ((a * temperature) / (b + temperature)) + Math.log(humidity / 100); + const dewPoint = (b * alpha) / (a - alpha); + return dewPoint.toFixed(2); +} + +function findHeatIndex(temperature, humidity) { + + const T = temperature; + const R = humidity; + const HI = -8.78469475556 + 1.61139411 * T + 2.33854883889 * R + -0.14611605 * T * R + -0.012308094 * Math.pow(T, 2) + -0.0164248277778 * Math.pow(R, 2) + 0.002211732 * Math.pow(T, 2) * R + 0.00072546 * T * Math.pow(R, 2) + -0.000003582 * Math.pow(T, 2) * Math.pow(R, 2); + return HI.toFixed(2); +} + +function findHumanThermalComfort(temperature, humidity, windSpeed) { + + const THI = temperature - ((0.55 - (0.55 * (humidity / 100))) * (temperature - 14.5)); + if (THI < 15) { + return "Cold"; + } else if (THI >= 15 && THI <= 25) { + return "Comfortable"; + } else { + return "Hot"; + } +} diff --git a/Calculators/Weather-Calculator/style.css b/Calculators/Weather-Calculator/style.css new file mode 100644 index 000000000..26b4b65b6 --- /dev/null +++ b/Calculators/Weather-Calculator/style.css @@ -0,0 +1,80 @@ +body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + margin: 0; + background: radial-gradient(#a07eff,#ffffff) ; +} + +.container { + text-align: center; + width: 30%; + background: #fff; + padding: 20px; + border-radius: 8px; +} + +.container h1{ + font-family:'Lucida Sans', Arial, sans-serif; + color:#4f1591; + font-size: 30px; +} + +.container h2, h3, h4{ + font-size: 15px; + text-align: left; + margin-left: 10px; +} + +input[type="number"] { + display: block; + width: 90%; + text-align: center; + padding: 10px; + margin: 10px 5px; + border: 1px solid #ccc; + border-radius: 50px; +} + +input[type="number"]:hover { + background-color: rgb(255, 230, 221); +} + +button { + padding: 10px 20px; + border: none; + background: #8d6fde; + color: #fff; + border-radius: 4px; + cursor: pointer; + margin-top: 10px; +} + +button:hover { + background: #7d62ca; + border-bottom: 3px solid #4f1591; +} + +.resultsContainer { + background-color: rgb(255, 230, 221); + border-radius: 8px; + border-right:3px solid #484848; + border-bottom:3px solid #484848; +} + +.results { + margin-top: 30px; + font-size: 15px; + text-align: left; +} + +.results p { + display: block; + width: 90%; + text-align: left; + padding: 8px; + margin: 10px 10px; + border-radius: 50px; +} diff --git a/index.html b/index.html index 198e46157..a4500a657 100644 --- a/index.html +++ b/index.html @@ -2106,6 +2106,20 @@