diff --git a/Calculators/Charles-Law-Calculator/README.md b/Calculators/Charles-Law-Calculator/README.md new file mode 100644 index 000000000..fb314affb --- /dev/null +++ b/Calculators/Charles-Law-Calculator/README.md @@ -0,0 +1,57 @@ +#

Charles Law Calculator

+ +## Description :- + +This is a web-based calculator that implements **Charles' Law**: + +\[(V_1 / T_1) = (V_2 / T_2)\] + +It allows users to calculate: + +- Final Volume \( V_2 \) +- Final Temperature \( T_2 \) + +The calculator dynamically updates based on user inputs and provides instant results. + +## Tech Stacks :- + +- HTML +- CSS +- JavaScript + +## Features :- + +- **Dynamic Formula Display**: The formula for Charles' Law is displayed on the website for reference. +- **Real-Time Results**: Automatically calculates the missing value when valid inputs are provided. +- **Responsive Design**: The calculator works seamlessly across devices. +- **Error Handling**: Guides the user with error messages for invalid or incomplete inputs. + +## How to Use :- + +1. Enter known values for \( V_1 \), \( T_1 \), and one of \( V_2 \) or \( T_2 \). +2. Click the "Calculate" button to get the result. +3. The missing value will be calculated using the formula: + \[(V_1 / T_1) = (V_2 / T_2)\] +4. Clear inputs or refresh the page to reset the calculator. + +## Example Calculations :- + +#### Case 1: Calculate Final Volume (\( V_2 \)) +- **Input**: + - Initial Volume (\( V_1 \)): `2 L` + - Initial Temperature (\( T_1 \)): `300 K` + - Final Temperature (\( T_2 \)): `450 K` +- **Output**: + - \( V_2 = (2 × 450) / 300 = 3 L\) + +#### Case 2: Calculate Final Temperature (\( T_2 \)) +- **Input**: + - Initial Volume (\( V_1 \)): `2 L` + - Initial Temperature (\( T_1 \)): `300 K` + - Final Volume (\( V_2 \)): `4 L` +- **Output**: + - \( T_2 = (4 × 300) / 2 = 600 K\) + +## Screenshots :- + +![image](https://github.com/user-attachments/assets/8ab75b48-15cf-4558-b7ab-be2a3d0d04d8) diff --git a/Calculators/Charles-Law-Calculator/assets/background.webp b/Calculators/Charles-Law-Calculator/assets/background.webp new file mode 100644 index 000000000..172004b52 Binary files /dev/null and b/Calculators/Charles-Law-Calculator/assets/background.webp differ diff --git a/Calculators/Charles-Law-Calculator/index.html b/Calculators/Charles-Law-Calculator/index.html new file mode 100644 index 000000000..05c164382 --- /dev/null +++ b/Calculators/Charles-Law-Calculator/index.html @@ -0,0 +1,35 @@ + + + + + + + + Charles Law Calculator + + + +
+

Charles' Law Calculator

+

Formula: (V₁ / T₁) = (V₂ / T₂)

+ + + + + + + + + + + + + + +
+
+ + + + + \ No newline at end of file diff --git a/Calculators/Charles-Law-Calculator/script.js b/Calculators/Charles-Law-Calculator/script.js new file mode 100644 index 000000000..e36f15c38 --- /dev/null +++ b/Calculators/Charles-Law-Calculator/script.js @@ -0,0 +1,26 @@ +function calculateCharlesLaw() { + const v1 = parseFloat(document.getElementById('v1').value); + const t1 = parseFloat(document.getElementById('t1').value); + const v2 = parseFloat(document.getElementById('v2').value); + const t2 = parseFloat(document.getElementById('t2').value); + + let resultText = ""; + + if (!isNaN(v1) && !isNaN(t1) && isNaN(v2) && !isNaN(t2)) { + // Calculate Final Volume (V2) + const v2Calculated = (v1 * t2) / t1; + resultText = `V₂ = (${v1} x ${t2}) / ${t1} = ${v2Calculated.toFixed(2)} liters`; + } else if (!isNaN(v1) && !isNaN(t1) && !isNaN(v2) && isNaN(t2)) { + // Calculate Final Temperature (T2) + const t2Calculated = (v2 * t1) / v1; + resultText = `T₂ = (${v2} x ${t1}) / ${v1} = ${t2Calculated.toFixed(2)} K`; + } else if (isNaN(v1) || isNaN(t1)) { + resultText = "Please enter valid values for initial volume (V₁) and initial temperature (T₁)."; + } else if (isNaN(v2) && isNaN(t2)) { + resultText = "Please provide either final volume (V₂) or final temperature (T₂) to calculate."; + } else { + resultText = "Invalid input combination. Please ensure only one value is missing for calculation."; + } + + document.getElementById('result').innerText = resultText; +} \ No newline at end of file diff --git a/Calculators/Charles-Law-Calculator/style.css b/Calculators/Charles-Law-Calculator/style.css new file mode 100644 index 000000000..b311fa4a7 --- /dev/null +++ b/Calculators/Charles-Law-Calculator/style.css @@ -0,0 +1,69 @@ +body { + font-family: Arial, sans-serif; + background-image: url('assets/background.webp'); + background-size: cover; + margin: 0; + padding: 0; + display: flex; + justify-content: center; + align-items: center; + height: 100%; + min-height: 100vh; +} + +.calculator { + background: rgba(255, 255, 255, 0.9); + padding: 20px; + border-radius: 8px; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); + width: 350px; + text-align: center; +} + +h1 { + font-size: 24px; + margin-bottom: 10px; +} + +.formula { + font-size: 16px; + margin-bottom: 20px; + color: #555; +} + +label { + font-size: 16px; + margin: 10px 0; + display: block; +} + +input { + width: calc(100% - 20px); + padding: 10px; + margin-bottom: 20px; + font-size: 16px; + border: 1px solid #ccc; + border-radius: 4px; +} + +button { + background-color: #007bff; + color: white; + padding: 10px 20px; + border: none; + border-radius: 4px; + font-size: 16px; + cursor: pointer; + margin-top: 10px; +} + +button:hover { + background-color: #0056b3; +} + +.result { + margin-top: 20px; + font-size: 18px; + font-weight: bold; + color: #333; +} \ No newline at end of file diff --git a/calculators.json b/calculators.json index bac64ecfc..e53d440e7 100644 --- a/calculators.json +++ b/calculators.json @@ -449,6 +449,12 @@ "link": "./Calculators/Centroid-Of-A-Triangle-Calculator/index.html", "source": "https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Centroid-Of-A-Triangle-Calculator" }, + { + "title": "Charles Law Calculator", + "description": "Calculates the gas volume or temperature using Charles' Law.", + "link": "./Calculators/Charles-Law-Calculator/index.html", + "source": "https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Charles-Law-Calculator" + }, { "title": "Chi-Square Calculator", "description": "Calculates the Chi-Square value of the data.",