Skip to content

Commit

Permalink
Added Rainwater Harvesting Calculator (#1413)
Browse files Browse the repository at this point in the history
  • Loading branch information
RajKhanke authored Jun 24, 2024
1 parent 80e0fc1 commit 153d53f
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Calculators/Rainwater-Harvesting-Calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# <p align="center">Rainwater Harvesting Calculator</p>

## Description :-

The Rainwater Harvesting Calculator is a web-based application that calculates the average annual rainwater that the harvesting tank can store (in liters) based on inputs fields such as:-
- height of the roof (in metres)
- width of the roof (in metres)
- Average annual rainfall (in mm) in the region
- Harvesting system efficiency (high , low ,medium)
- Storage capacity of tank (in litres).

## Tech Stacks :-

- HTML
- CSS
- JavaScript

## Working :-

- The working is based on below formulas :-
1) area = length * width
2) totalRainwater = area * (rainfall / 1000) * efficiency * 1000

## Screenshots :-

![image](https://github.com/Rakesh9100/CalcDiverse/assets/73993775/14010ac5-5c23-44c8-bdbb-45281df4bd73)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions Calculators/Rainwater-Harvesting-Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Rainwater Harvesting Calculator</title>
</head>
<body>
<div class="container">
<h1>Rainwater Harvesting Calculator</h1>
<form id="rainwater-form">
<label for="length">Length of the roof (in meters):</label>
<input type="number" id="length" required>

<label for="width">Width of the roof (in meters):</label>
<input type="number" id="width" required>

<label for="rainfall">Average annual rainfall (in mm):</label>
<input type="number" id="rainfall" required>

<label for="efficiency">Harvesting system efficiency:</label>
<select id="efficiency" required>
<option value="0.75">Low</option>
<option value="0.83">Medium</option>
<option value="0.90">High</option>
</select>

<label for="capacity">Storage capacity of tank (in litres):</label>
<input type="number" id="capacity" required>

<button type="button" onclick="calculateRainwater()">Calculate</button>
</form>
<div id="result" style="display: none;">
<h2>Total Rainwater Collected Annually:</h2>
<p id="total-water"></p>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
21 changes: 21 additions & 0 deletions Calculators/Rainwater-Harvesting-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function calculateRainwater() {
// Get the input values
const length = parseFloat(document.getElementById('length').value);
const width = parseFloat(document.getElementById('width').value);
const rainfall = parseFloat(document.getElementById('rainfall').value);
const efficiency = parseFloat(document.getElementById('efficiency').value);
const capacity = parseFloat(document.getElementById('capacity').value);

// Calculate the roof area
const area = length * width;

// Calculate the total rainwater collected annually
const totalRainwater = area * (rainfall / 1000) * efficiency * 1000;

// Display the result
const resultElement = document.getElementById('total-water');
resultElement.textContent = `${totalRainwater.toFixed(2)} litres`;

// Show the result container
document.getElementById('result').style.display = 'block';
}
70 changes: 70 additions & 0 deletions Calculators/Rainwater-Harvesting-Calculator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
body {
background-image: url(./assets/background.jpg);
background-size: cover;
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}

.container {
background-color: rgba(255, 255, 255, 0.8);
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
text-align: center;
width: 300px;
}

h1 {
color: #333;
font-size: 1.5em;
}

form {
display: flex;
flex-direction: column;
}

label {
margin-top: 10px;
color: #333;
text-align: left;
}

input,
select {
margin-top: 5px;
padding: 8px;
border-radius: 5px;
border: 1px solid #333;
font-size: 0.9em;
text-align: center;
}

button {
margin-top: 20px;
padding: 10px;
background-color: #007BFF;
color: white;
border: none;
border-radius: 5px;
font-size: 1em;
cursor: pointer;
}

button:hover {
background-color: #0056b3;
}

#result {
margin-top: 20px;
color: #333;
}

#total-water {
font-size: 1.5em;
font-weight: bold;
}
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2878,6 +2878,20 @@ <h3>Reverse Polish Notation calculator which represents expressions by placeing
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Rainwater Harvesting Calculator</h2>
<h3>Calculates the annual rainwater that can be harvested by the storage tank in liters.</h3>
<div class="card-footer">
<a href="./Calculators/Rainwater-Harvesting-Calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Rainwater-Harvesting-Calculator" title="Source Code" target="_blank">
<img src="./assets/images/github.png" alt="Source Code"></img>
</a>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Random Letter Calculator</h2>
Expand Down

0 comments on commit 153d53f

Please sign in to comment.