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 Niven Number Calculator #1067

Closed
wants to merge 12 commits into from
16 changes: 16 additions & 0 deletions Calculators/BMR-Calculator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,19 @@ Calculates the Basal Metabolic Rate of a person using height, weight & age.
## Screenshots :-

![Screenshot 2024-05-10 233027](https://github.com/Rakesh9100/CalcDiverse/assets/132455412/92808faf-d5b6-4fb3-83c0-b35d4623e893)

# <p align="center">BMR Calculator</p>

## Description :-

Calculates the Basal Metabolic Rate of an individual.

## Tech Stacks :-

- HTML
- CSS
- JavaScript

## Screenshots :-


32 changes: 32 additions & 0 deletions Calculators/BMR-Calculator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,35 @@ <h1>BMR Calculator</h1>
<script src="script.js"></script>
</body>
</html>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BMR Calculator</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="calculator">
<h1>BMR Calculator</h1>
<div class="form">
<label for="gender">Gender:</label>
<select id="gender">
<option value="male">Male</option>
<option value="female">Female</option>
</select>
<label for="age">Age (years):</label>
<input type="number" id="age" min="0" required>
<label for="weight">Weight (kg):</label>
<input type="number" id="weight" min="0" required>
<label for="height">Height (cm):</label>
<input type="number" id="height" min="0" required>
<button onclick="calculateBMR()">Calculate</button>
</div>
<div id="result"></div>
</div>

<script src="main.js"></script>
</body>
</html>
16 changes: 16 additions & 0 deletions Calculators/BMR-Calculator/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function calculateBMR() {
var gender = document.getElementById("gender").value;
var age = parseInt(document.getElementById("age").value);
var weight = parseFloat(document.getElementById("weight").value);
var height = parseFloat(document.getElementById("height").value);

var bmr;
if (gender === "male") {
bmr = 10 * weight + 6.25 * height - 5 * age + 5;
} else {
bmr = 10 * weight + 6.25 * height - 5 * age - 161;
}

document.getElementById("result").innerHTML = "Your Basal Metabolic Rate (BMR) is " + bmr.toFixed(2) + " calories per day.";
}

63 changes: 63 additions & 0 deletions Calculators/BMR-Calculator/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,66 @@ button:hover {
font-size: 18px;
color: #333;
}

body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color:#fff;
background-image: linear-gradient(90deg,#1CA7EC,#1F2F98);
}

.calculator {
background-color:#fff;
width: 400px;
margin: 50px auto;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

h1 {
text-align: center;
color: #333;
}

.form {
margin-bottom: 20px;
}

label {
display: block;
margin-bottom: 8px;
color: #555;
}

input[type="number"],
select {
width: 100%;
padding: 8px;
margin-bottom: 12px;
border: 1px solid #ccc;
border-radius: 4px;
}

button {
width: 100%;
padding: 10px;
background-color: #4caf50;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease;
}

button:hover {
background-color: #45a049;
}

#result {
text-align: center;
font-size: 18px;
color: #333;
}

17 changes: 17 additions & 0 deletions Calculators/Kaprekar-Number-Calculator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,20 @@ A simple web-based calculator to find whether the number is Kaprekar number or n
![image](https://github.com/Rakesh9100/CalcDiverse/assets/73993775/f1ef8fda-dbab-4856-8ea3-e4f06a8bb2b8)

![image](https://github.com/Rakesh9100/CalcDiverse/assets/73993775/331e2212-7c05-408f-a75e-2aa99ef7fe67)

# <p align="center">Kaprekar Number Calculator</p>

## Description :-

A simple web-based calculator to find whether the number is Kaprekar number or not.
Number logic:A number's square can be split into two parts that add up to the original number.

## Tech Stacks :-

- HTML
- CSS
- JavaScript

## Screenshots :-


49 changes: 49 additions & 0 deletions Calculators/Kaprekar-Number-Calculator/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
background-image: linear-gradient(90deg, #1CA7EC, #1F2F98);
margin: 0;
}

.container {
text-align: center;
background: #fff;
padding: 2rem;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

h1 {
margin-bottom: 1rem;
}

input {
padding: 0.5rem;
width: 200px;
margin-bottom: 1rem;
border: 1px solid #ccc;
border-radius: 4px;
}

button {
padding: 0.5rem 1rem;
border: none;
background-color: #007bff;
color: #fff;
border-radius: 4px;
cursor: pointer;
font-size: 1rem;
}

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

p {
margin-top: 1rem;
font-size: 1.2rem;
}
18 changes: 18 additions & 0 deletions Calculators/Niven-Number-Calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# <p align="center">Niven Number Calculator</p>

## Description :-

A simple web-based calculator to find whether the number is Niven number or not.
Number logic:A number that is divisible by the sum of its digits is called a Niven number.

## Tech Stacks :-

- HTML
- CSS
- JavaScript

## Screenshots :-

![Screenshot 2024-06-01 203757](https://github.com/Nayanika1402/CalcDiverse/assets/132455412/f21e3eaf-945f-4f70-a853-144e58e5b670)

![Screenshot 2024-06-01 203808](https://github.com/Nayanika1402/CalcDiverse/assets/132455412/d8a0c461-53cd-4fc9-a99f-5d0e8e34e668)
18 changes: 18 additions & 0 deletions Calculators/Niven-Number-Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Niven Number Calculator</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Niven Number Calculator</h1>
<input type="number" id="numberInput" placeholder="Enter a number" />
<button onclick="checkNivenNumber()">Check</button>
<p id="result"></p>
</div>
<script src="script.js"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions Calculators/Niven-Number-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function checkNivenNumber() {
const numberInput = document.getElementById('numberInput').value;
const resultElement = document.getElementById('result');

if (numberInput === '') {
resultElement.textContent = 'Please enter a number.';
return;
}

const number = parseInt(numberInput);
const sumOfDigits = number
.toString()
.split('')
.map(Number)
.reduce((acc, digit) => acc + digit, 0);

if (number % sumOfDigits === 0) {
resultElement.textContent = `${number} is a Niven number.`;
} else {
resultElement.textContent = `${number} is not a Niven number.`;
}
}
47 changes: 47 additions & 0 deletions Calculators/Niven-Number-Calculator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
background-image: linear-gradient(90deg, #1CA7EC, #1F2F98);
}

.container {
text-align: center;
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

h1 {
margin-bottom: 20px;
}

input {
padding: 10px;
margin-right: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}

button {
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #007bff;
color: white;
cursor: pointer;
}

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

p {
margin-top: 20px;
font-size: 1.2em;
}
28 changes: 28 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,20 @@ <h3>Given any number, it reaches to Four.</h3>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>BMR Calculator</h2>
<h3>Calculates the Basal Metabolic Rate of a person using Height,Weight & Age.</h3>
<div class="card-footer">
<a href="./Calculators/BMR-Calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/BMR-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>Book Reading Time Calculator</h2>
Expand Down Expand Up @@ -1562,6 +1576,20 @@ <h3>Calculates the days remaining until the next birthday.</h3>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Niven Number Calculator</h2>
<h3>Checks whether the number is Niven number or not.</h3>
<div class="card-footer">
<a href="./Calculators/Niven-Number-Calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Niven-Number-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>Number Of Days Calculator</h2>
Expand Down