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 Anagram Calculator #886

Merged
merged 8 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Calculators/Anagram-Calculator/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# <p align="center">Anagram Calculator</p>

## Description :-

Calculator which is used to check whether the two words are Anagram or not.

## Tech Stacks :-

- HTML
- CSS
- JavaScript

## Screenshots :-

![image](https://github.com/Rakesh9100/CalcDiverse/assets/73993775/6aea3fe3-e2d5-46dc-8639-e34b575a6631)
26 changes: 26 additions & 0 deletions Calculators/Anagram-Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!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>Anagram Calculator</title>
</head>
<body>
<div class="container">
<h1><marquee>Anagram Calculator</marquee></h1>
<div class="input-group">
<label for="word1"><b>Enter the first word:</b></label>
<input type="text" id="word1" placeholder="First word">
</div>
<div class="input-group">
<label for="word2"><b>Enter the second word:
<b></label>
<input type="text" id="word2" placeholder="Second word">
</div>
<button onclick="checkAnagram()">Check Anagram</button>
<div id="result"></div>
</div>
<script src="script.js"></script>
</body>
</html>
23 changes: 23 additions & 0 deletions Calculators/Anagram-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function checkAnagram() {
const word1 = document.getElementById('word1').value.trim().toLowerCase();
const word2 = document.getElementById('word2').value.trim().toLowerCase();

if (word1 === '' || word2 === '') {
alert('Please enter both words.');
return;
}

const sortedWord1 = word1.split('').sort().join('');
const sortedWord2 = word2.split('').sort().join('');

const resultDiv = document.getElementById('result');
if (sortedWord1 === sortedWord2) {
resultDiv.innerHTML = '<p>The words are anagrams!</p>';
resultDiv.style.color = 'green';
resultDiv.button.color='green';
} else {
resultDiv.innerHTML = '<p>The words are not anagrams.</p>';
resultDiv.style.color = 'red';
resultDiv.button.color='red';
}
}
67 changes: 67 additions & 0 deletions Calculators/Anagram-Calculator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
body {
font-family: 'Arial', sans-serif;
background-color: blue;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

.container {
background-color: #ffffff;
padding: 30px 40px;
box-shadow: 0 35px 50px rgba(0, 0, 0, 0.1);
border-radius: 8px;
text-align: center;
max-width: 400px;
width: 100%;
}

h1 {
color: #333333;
margin-bottom: 20px;
font-size: 24px;
}

.input-group {
margin-bottom: 20px;
text-align: left;
}

label {
display: block;
margin-bottom: 5px;
color: #555555;
}

input[type="text"] {
padding: 10px;
width: 100%;
border: 1px solid #cccccc;
border-radius: 5px;
font-size: 16px;
box-sizing: border-box;
}

button {
padding: 10px 20px;
background-color: #007bff;
color: #ffffff;
border: none;
border-radius: 4px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s ease;
}

button:hover {
background-color: green;
}

#result {
margin-top: 20px;
font-size: 18px;
color: #333333;
}

14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,20 @@ <h3>Calculates the level of the air quality using AQI index as input.</h3>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Anagram Calculator</h2>
<h3>Calculator which checks whether the two words are Anagram or not.</h3>
<div class="card-footer">
<a href="./Calculators/Anagram-Calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Anagram-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>Antilog Calculator</h2>
Expand Down