Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Height Calculator #1150

Merged
merged 13 commits into from
Jun 5, 2024
19 changes: 19 additions & 0 deletions Calculators/Height-Calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# <p align="center">Height Calculator</p>

## Description :-

The Height Calculator is designed to perform various height conversions. It allows users to convert between different units such as feet, meters, and inches.

## Tech Stacks :-

- HTML
- CSS
- JavaScript

## Features :-

- Convert feet to meters and vice versa.
- Convert inches to feet and vice versa.
- Convert inches to meters and vice versa.

## Screenshot :- ![screenshot](image.png)
Binary file added Calculators/Height-Calculator/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions Calculators/Height-Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Height Calculator</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="wrapper">
<div class="Height-Converter">
<h1>Height Converter</h1>
<label for="conversionType">Select Conversion:</label>
<select id="conversionType" onchange="updateInputs()">
<option value="" disabled selected>Select Conversion</option>
<option value="feet-to-meter">Feet to Meters</option>
<option value="meter-to-feet">Meters to Feet</option>
<option value="inch-to-feet">Inches to Feet</option>
<option value="feet-to-inch">Feet to Inches</option>
<option value="inch-to-meter">Inches to Meters</option>
<option value="meter-to-inch">Meters to Inches</option>
</select>

<div id="inputContainer">
<label for="inputValue" id="inputLabel">Enter Value</label>
<input type="number" id="inputValue" min="0" placeholder="Enter Value">
</div>
<button onclick="convert()">Convert</button>

<div id="result"></div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
62 changes: 62 additions & 0 deletions Calculators/Height-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
function updateInputs() {
const conversionType = document.getElementById('conversionType').value;
const inputLabel = document.getElementById('inputLabel');

switch (conversionType) {
case 'feet-to-meter':
inputLabel.textContent = 'Enter Feet';
break;
case 'meter-to-feet':
inputLabel.textContent = 'Enter Meters';
break;
case 'inch-to-feet':
inputLabel.textContent = 'Enter Inches';
break;
case 'feet-to-inch':
inputLabel.textContent = 'Enter Feet';
break;
case 'inch-to-meter':
inputLabel.textContent = 'Enter Inches';
break;
case 'meter-to-inch':
inputLabel.textContent = 'Enter Meters';
break;
default:
inputLabel.textContent = 'Enter Value';
}
}

function convert() {
const conversionType = document.getElementById('conversionType').value;
const inputValue = parseFloat(document.getElementById('inputValue').value);
let result;

if (isNaN(inputValue) || inputValue < 0) {
result = 'Please enter a valid non-negative number';
} else {
switch (conversionType) {
case 'feet-to-meter':
result = `${inputValue} Feet is ${(inputValue * 0.3048).toFixed(2)} Meters`;
break;
case 'meter-to-feet':
result = `${inputValue} Meters is ${(inputValue / 0.3048).toFixed(2)} Feet`;
break;
case 'inch-to-feet':
result = `${inputValue} Inches is ${(inputValue / 12).toFixed(2)} Feet`;
break;
case 'feet-to-inch':
result = `${inputValue} Feet is ${(inputValue * 12).toFixed(2)} Inches`;
break;
case 'inch-to-meter':
result = `${inputValue} Inches is ${(inputValue * 0.0254).toFixed(2)} Meters`;
break;
case 'meter-to-inch':
result = `${inputValue} Meters is ${(inputValue / 0.0254).toFixed(2)} Inches`;
break;
default:
result = 'Please select a conversion type';
}
}

document.getElementById('result').textContent = result;
}
78 changes: 78 additions & 0 deletions Calculators/Height-Calculator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
font-family: Arial, sans-serif;
background: linear-gradient(135deg, #72edf2 10%, #5151e5 100%);
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

#wrapper {
background-color: #ffffff;
padding: 40px;
border-radius: 15px;
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
transition: box-shadow 0.3s ease;
width: 400px;
}

#wrapper:hover {
box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
}

.Height-Converter {
text-align: center;
}

h1 {
margin-bottom: 20px;
color: #00796b;
}

label {
display: block;
margin-top: 20px;
font-weight: bold;
color: #004d40;
}

input, select, button {
width: 100%;
padding: 12px;
margin-top: 10px;
border-radius: 5px;
border: 1px solid #ccc;
transition: border-color 0.3s ease, background-color 0.3s ease;
}

input:focus, select:focus {
border-color: #00796b;
background-color: #e0f2f1;
}

button {
background-color: #00796b;
color: #ffffff;
border: none;
cursor: pointer;
transition: background-color 0.3s ease;
}

button:hover {
background-color: #004d40;
}

#result {
margin-top: 20px;
font-size: 1.2em;
font-weight: bold;
color: #00796b;
}
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,20 @@ <h3>Calculates the heart rate monitors.</h3>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Height Calculator</h2>
<h3>Intercoverts heights between it's various units such as Feet, Inches and Meters</h3>
<div class="card-footer">
<a href="./Calculators/Height-Calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Height-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>Hexadecimal Calculator</h2>
Expand Down