<?php
include('includes/header.php');
?>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Square Root Calculator</title>
<!-- <style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #f4f4f9;
}
header {
background-color: #333;
color: white;
width: 100%;
padding: 10px 0;
text-align: center;
font-size: 24px;
}
footer {
background-color: #333;
color: white;
width: 100%;
padding: 10px 0;
text-align: center;
position: absolute;
bottom: 0;
}
.calculator-container {
text-align: center;
margin-top: 50px;
padding: 20px;
background-color: white;
border-radius: 10px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
.calculator-container input, .calculator-container button {
padding: 10px;
margin: 10px;
font-size: 16px;
}
.calculator-container button {
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
}
.calculator-container button:hover {
background-color: #45a049;
}
.result {
font-size: 18px;
font-weight: bold;
}
</style>-->
</head>
<body>
<header>
Square Root Calculator
</header>
<div class="calculator-container">
<h2>Enter a number to calculate its square root</h2>
<label for="number"></label><input type="number" id="number" placeholder="Enter number" />
<button onclick="calculateSquareRoot()">Calculate</button>
<div id="result" class="result"></div>
</div>
<footer>
© 2024 Square Root Calculator. All Rights Reserved.
</footer>
<script>
function calculateSquareRoot() {
let number = document.getElementById('number').value;
let resultDiv = document.getElementById('result');
// Check if the input is a number
if (number === '' || isNaN(number) || number < 0) {
resultDiv.innerHTML = 'Please enter a valid positive number.';
} else {
let result = Math.sqrt(number);
resultDiv.innerHTML = `The square root of ${number} is: ${result.toFixed(2)}`;
}
}
</script>
<?php
include('includes/footer.php');
?>