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

[004] Number table #71

Closed
Show file tree
Hide file tree
Changes from 8 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
50 changes: 27 additions & 23 deletions 001-counter-app/bongo-dev/index.html
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let us not delete bongodev javascript file

Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Counter App</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Counter App</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
</head>

<body class="bg-gray-100 flex items-center justify-center min-h-screen">

<!-- Counter App Container -->
<div class="bg-white shadow-lg rounded-lg p-8 text-center">
<h1 class="text-2xl font-bold text-gray-800 mb-4">Counter App</h1>

<!-- Counter Display -->
<div id="counter" class="text-4xl font-bold text-gray-700">0</div>

<!-- Counter Controls -->
<div class="mt-6">
<button id="increment"
class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded mr-2">+</button>
<button id="decrement" class="bg-red-500 hover:bg-red-600 text-white font-bold py-2 px-4 rounded ml-2">-</button>
<body class="bg-gray-100 flex items-center justify-center min-h-screen">
<div class="bg-white shadow-lg rounded-lg p-8 text-center">
<h1 id="title" class="text-2xl font-bold text-gray-800 mb-4"></h1>
<div id="counter" class="text-4xl font-bold text-gray-700">0</div>
<div class="mt-6">
<button
id="increment"
class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded mr-2"
>
+
</button>
<button
id="decrement"
class="bg-red-500 hover:bg-red-600 text-white font-bold py-2 px-4 rounded ml-2"
>
-
</button>
</div>
</div>
</div>

<script src="./script.js"></script>
</body>

</html>
<script src="./script.js"></script>
</body>
</html>
36 changes: 36 additions & 0 deletions 001-counter-app/zubayer/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Counter App</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>

<body class="bg-gray-100 flex items-center justify-center min-h-screen">
<div class="bg-white shadow-lg rounded-lg p-8 text-center">
<h1 id="title" class="text-2xl font-bold text-gray-800 mb-4"></h1>
<div id="counter" class="text-4xl font-bold text-gray-700">0</div>
<div class="mt-6">
<button
id="increment"
class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded mr-2"
>
+
</button>
<button
id="decrement"
class="bg-red-500 hover:bg-red-600 text-white font-bold py-2 px-4 rounded ml-2"
>
-
</button>
</div>
</div>
</div>

<script src="./script.js"></script>
</body>

<script src="./script.js"></script>
</body>
</html>
29 changes: 29 additions & 0 deletions 001-counter-app/zubayer/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
console.log('JavaScript added');
let titleElement = document.getElementById('title');
titleElement.innerText = 'Counter App';

let count = 0;
const counterElement = document.getElementById('counter');
const incrementButton = document.getElementById('increment');
const decrementButton = document.getElementById('decrement');

function increaseCount() {
if (count === 10) {
alert('Count overflow!');
}
else{
count++;
counterElement.innerText = count;
}

}

incrementButton.addEventListener('click', increaseCount);
decrementButton.addEventListener('click', function () {
if (count === 0) {
alert('Count will be negative');
} else {
count--;
counterElement.innerText = count;
}
});
29 changes: 29 additions & 0 deletions 002-number-comparator/zubayer/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Number Comparator App</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>

<body class="bg-gray-100 h-screen flex items-center justify-center">
<div class="bg-white p-6 rounded-lg shadow-lg text-center">
<h1 class="text-2xl font-bold mb-4">Number Comparator App</h1>
<div class="flex flex-col gap-4">
<input type="number" id="number1" placeholder="Enter first number" class="border p-2 rounded" value="0" />

<input type="number" id="number2" placeholder="Enter second number" class="border p-2 rounded" value="0" />
</div>

<button id="compare" class="mt-4 bg-blue-500 text-white py-2 px-4 rounded">Compare</button>
<button id="reset" class="mt-4 hover:bg-green-600 bg-yellow-500 text-white py-2 px-4 rounded">Reset</button>
<div id="result" class="mt-4 text-x1 font-bold"></div>

<script src="./number-comparator.js"></script>

</body>

</html>

51 changes: 51 additions & 0 deletions 002-number-comparator/zubayer/number-comparator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Select elements by ID
const number1Input = document.getElementById("number1");
const number2Input = document.getElementById("number2");
const compareButton = document.getElementById("compare");
const resetButton = document.getElementById("reset");
const result = document.getElementById("result");

const ERROR_CLASS = 'border-red-500';
function resetErrorStyles(){
number1Input.classList.remove(ERROR_CLASS);
number2Input.classList.remove(ERROR_CLASS);
}

function isValidInput(){
resetErrorStyles();

if(!number1Input.value){
number1Input.classList.add(ERROR_CLASS);
return false;
}
if(!number2Input.value){
number2Input.classList.add(ERROR_CLASS);
return false;
}
return true;
}

// Add event listener for the Compare button
compareButton.addEventListener('click', function () {
if(!isValidInput()){
return;
}
const number1 = parseFloat(number1Input.value);
const number2 = parseFloat(number2Input.value);

if (number1 > number2) {
result.innerText = "First Number is larger";
} else if (number1 < number2) {
result.innerText = "Second Number is larger";
} else {
result.innerText = "Both numbers are equal";
}
});

resetButton.addEventListener('click', function(){
number1.value = '0';
number2.value = '0';
result.innerText = '';
resetErrorStyles();

});
62 changes: 62 additions & 0 deletions 003-grade-comparator/zubayer/grade-calculator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const scoreInput = document.getElementById("score");
const calculateGradeButton = document.getElementById("calculate-btn");
const result = document.getElementById("result");
const resetButton = document.getElementById("reset");
const errorMessage = document.getElementById("error-message");

const ERROR_CLASS = "border-red-500";

function resetErrorStyles() {
scoreInput.classList.remove(ERROR_CLASS);
errorMessage.classList.add("hidden");
}

function isValidInput() {
resetErrorStyles();
if (!scoreInput.value) {
scoreInput.classList.add(ERROR_CLASS);
errorMessage.classList.remove("hidden");
errorMessage.textContent = "Please enter a valid score!!";
return false;
}
if (scoreInput.value < 0 || scoreInput.value > 100) {
scoreInput.classList.add(ERROR_CLASS);
errorMessage.classList.remove("hidden");
errorMessage.textContent = "Please enter score between 0 to 100!!";
return false;
}
return true;
}

calculateGradeButton.addEventListener("click", function () {
if (!isValidInput()) {
return;
}

let score = parseFloat(scoreInput.value);

if (score >= 0 && score < 33) {
result.textContent = "F (You have to improve)";
} else if (score >= 33 && score < 40) {
result.textContent = "D (You barely passed, keep working harder)";
} else if (score >= 40 && score < 50) {
result.textContent = "C (Needs improvement)";
} else if (score >= 50 && score < 60) {
result.textContent = "B (Good, but aim higher)";
} else if (score >= 60 && score < 70) {
result.textContent = "A- (Well done, you are improving!)";
} else if (score >= 70 && score < 80) {
result.textContent = "A (Very good, keep up the great work!)";
} else if (score >= 80 && score <= 100) {
result.textContent = "A+ (Excellent! Keep shining!)";
} else {
result.textContent =
"Invalid Score (Please enter a score between 0 and 100)";
}
});

resetButton.addEventListener("click", function () {
scoreInput.value = "";
result.textContent = "";
resetErrorStyles();
});
28 changes: 28 additions & 0 deletions 003-grade-comparator/zubayer/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">
<title>Grade Calculator</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
</head>

<body class="bg-gray-100 h-screen flex items-center justify-center">
<div class="bg-white p-6 rounded-lg shadow-lg text-center">
<h1 class="text-2xl font-bold mb-4">Grade Calculator</h1>
<!-- Input Field for the Score -->
<input type="number" id="score" placeholder="Enter your score" class="hover:bg-yellow-100 border p-2 rounded w-full" min="0"
max="100" />
<p id="error-message" class="hidden"></p>
<!-- Button to Calculate Grade -->
<button id="calculate-btn" class="mt-4 hover:bg-red-600 bg-gray-500 text-white py-2 px-4 rounded">Calculate Grade</button>
<button id="reset" class="mt-4 hover:bg-blue-600 bg-green-500 text-white py-2 px-4 rounded">Reset</button>

<!-- Display Result -->
<div id="result" class="text-yellow-700 mt-4 text-xl font-bold"></div>
</div>

<!-- Include JavaScript -->
<script src="grade-calculator.js"></script>
</body>
32 changes: 32 additions & 0 deletions 004-number-table/zubayer/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>Multiplication Table Generator</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
</head>

<body class="bg-gray-100 h-screen flex items-center justify-center">
<div class="bg-white p-6 rounded-lg shadow-lg text-center">
<h1 class="text-2xl font-bold mb-4">Multiplication Table Generator</h1>

<!-- Input field for the number -->
<input type="number" id="input-number" placeholder="Enter a number" class="border p-2 rounded w-full" value="1" />

<!-- Button to generate the multiplication table -->
<button id="generate" class="mt-4 bg-blue-500 text-white py-2 px-4 rounded">Generate Table</button>
<button id="reset-btn" class="mt-4 bg-blue-500 hover:bg-green-700 text-white py-2 px-4 rounded">Reset </button>
<!-- Display area for the multiplication table -->
<div id="table-container" class="mt-4">
<table class="table-auto border border-slate-700 w-full">
<tbody id="table-body">
</tbody>
</table>
</div>
</div>

<!-- Include JavaScript -->
<script src="./multiplication-table.js"></script>
</body>
Loading