Skip to content

Commit

Permalink
added work work-life-balance calc
Browse files Browse the repository at this point in the history
  • Loading branch information
Nishakulkarni06 committed Jan 8, 2025
1 parent a66ed83 commit d4a6855
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 0 deletions.
Binary file added Calculators/Work-Life-Balance-Calc/bcg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions Calculators/Work-Life-Balance-Calc/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Work-Life Balance Calculator</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Work-Life Balance Calculator</h1>
<form id="balance-form">
<label for="work">Work Hours:</label>
<input type="number" id="work" required min="0" max="24" placeholder="Enter hours for work" required>
<br/>
<label for="personal">Personal Care Hours:</label>
<input type="number" id="personal" required min="0" max="24" placeholder="Enter hours for personal care" required>
<br/>
<label for="leisure">Leisure Hours:</label>
<input type="number" id="leisure" required min="0" max="24" placeholder="Enter hours for leisure" required>

<button type="button" id="calculate">Calculate</button>
</form>
<div id="result"></div>
</div>
<script src="script.js"></script>
</body>
</html>
23 changes: 23 additions & 0 deletions Calculators/Work-Life-Balance-Calc/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// script.js
document.getElementById('calculate').addEventListener('click', () => {
const work = parseFloat(document.getElementById('work').value) || 0;
const personal = parseFloat(document.getElementById('personal').value) || 0;
const leisure = parseFloat(document.getElementById('leisure').value) || 0;

const totalHours = work + personal + leisure;
if(totalHours > 24){
alert("Enter valid time");
return;
}
const balanceScore = ((personal + leisure) / 24).toFixed(2);

const resultDiv = document.getElementById('result');
resultDiv.innerHTML = `
<p>Total Hours: ${totalHours} / 24</p>
<p>Work-Life Balance Score: ${balanceScore}</p>
<p>${balanceScore >= 0.5 ? 'Good Balance!' : 'You need more personal/leisure time.'}</p>
`;
});



67 changes: 67 additions & 0 deletions Calculators/Work-Life-Balance-Calc/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* styles.css */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-image: url('bcg.jpg');
background-repeat: no-repeat;
background-size: cover;
color: #333;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

.container {
background: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
width: 450px;
}

h1 {
font-size: 24px;
margin-bottom: 20px;
text-align: center;
}

label {
display: block;
margin-top: 10px;
font-size: 14px;
}

input {
width: 100%;
padding: 7px;
margin-top: 5px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 14px;
padding-right: 5px;
}

button {
width: 100%;
padding: 10px;
background: #007bff;
color: #fff;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}

button:hover {
background: #0056b3;
}

#result {
margin-top: 20px;
text-align: center;
font-size: 16px;
font-weight: bold;
}

0 comments on commit d4a6855

Please sign in to comment.