diff --git a/001-counter-app/Dipu/index.html b/001-counter-app/Dipu/index.html new file mode 100644 index 0000000..74828d7 --- /dev/null +++ b/001-counter-app/Dipu/index.html @@ -0,0 +1,33 @@ + + + + + + + Counter App + + + + + + + +
+

Counter App

+ + +
0
+ + +
+ + + +
+
+ + + + + \ No newline at end of file diff --git a/001-counter-app/Dipu/script.js b/001-counter-app/Dipu/script.js new file mode 100644 index 0000000..97691fe --- /dev/null +++ b/001-counter-app/Dipu/script.js @@ -0,0 +1,34 @@ +let count=0; +const counterElement=document.getElementById('counter'); +const incrementButton=document.getElementById('Increment'); +const resetButton=document.getElementById('reset'); +function increaseCount(){ + if(count ==10) + { + alert('Overflow'); + } + else{ + count=count+1; + counterElement.innerText=count; + } +} +incrementButton.addEventListener('click', increaseCount); +function decreaseCount() +{ + if(count==0) + { + alert('Count can not be negative'); + } + else{ + count=count-1; + counterElement.innerText=count; + } +} +function reset(){ + count=0; + counterElement.innerText=count; +} +resetButton.addEventListener('click',reset) + +const decrementButton=document.getElementById('decrement'); +decrementButton.addEventListener('click',decreaseCount ); \ No newline at end of file diff --git a/002-number-comparator/Dipu/index.html b/002-number-comparator/Dipu/index.html new file mode 100644 index 0000000..9fc11dd --- /dev/null +++ b/002-number-comparator/Dipu/index.html @@ -0,0 +1,28 @@ + + + + + + Number Comparator App + + + + + +
+

Number Comparator App

+ +
+ + +
+ + + + +
+
+ + + + \ No newline at end of file diff --git a/002-number-comparator/Dipu/number-comparator.js b/002-number-comparator/Dipu/number-comparator.js new file mode 100644 index 0000000..b3fae16 --- /dev/null +++ b/002-number-comparator/Dipu/number-comparator.js @@ -0,0 +1,47 @@ +const inputNum1 = document.getElementById('number1'); +const inputnum2 = document.getElementById('number2'); +const comparatorButton = document.getElementById('compare'); +const result = document.getElementById('result'); +const Erro_Message = 'border-red-500'; +function ErrorStyle() { + inputNum1.classList.remove(Erro_Message); + inputnum2.classList.remove(Erro_Message); + return; + +} +function isvalidnumber() { + ErrorStyle(); + if (!inputNum1.value) { + inputNum1.classList.add(Erro_Message); + + return false; + } + if (!inputnum2.value) { + inputnum2.classList.add(Erro_Message); + return false; + } + return true; +} +comparatorButton.addEventListener('click', function () { + if (!isvalidnumber()) { + return; + } + const number1 = parseFloat(inputNum1.value); + const number2 = parseFloat(inputnum2.value); + if (number1 > number2) { + result.innerText = 'First number is Greater'; + } + else if (number1 < number2) { + result.innerText = 'Second Number is Greater'; + } + else { + result.innerText = 'Both are Equal'; + } +}); +const resetButton = document.getElementById('reset'); +resetButton.addEventListener('click', function () { + inputNum1.value = '0'; + inputnum2.value = '0'; + result.innerText = ' '; + ErrorStyle(); +}); \ No newline at end of file diff --git a/003-grade-calculator/Dipu/grade-calculator.js b/003-grade-calculator/Dipu/grade-calculator.js new file mode 100644 index 0000000..b47f20d --- /dev/null +++ b/003-grade-calculator/Dipu/grade-calculator.js @@ -0,0 +1,83 @@ +const numberInput = document.getElementById('score'); +const calculatorButton = document.getElementById('calculate-btn'); +const result = document.getElementById('result'); + +calculatorButton.addEventListener('click', function () { + + if (isEmptyInput()) { + errormessge(); + result.innerText = 'Please enter valid marks'; + + return; + } + const number = parseFloat(numberInput.value); + if (isInvalid(number)) { + + result.innerText = 'Please enter valid marks'; + + return; + } + + const grade = calculateGrade(number); + result.innerText = grade; +}); +const ERROR_MESS = 'border-red-500'; +function errormessge() { + numberInput.classList.add(ERROR_MESS); + +} +function isEmptyInput() { + if (!numberInput.value) { + return true; + } + return false; + +} +function isInvalid(marks) { + if (marks > 100 || marks < 0) { + return true; + } + return false; +} + +function calculateGrade(marks) { + let grade = ' '; + if (marks > 100 || marks < 0) { + grade = 'Invalid Marks'; + } + else if (marks <= 100 && marks >= 80) { + grade = 'A+'; + } + else if (marks < 80 && marks >= 70) { + grade = 'A'; + } + else if (marks < 70 && marks >= 60) { + grade = 'A-'; + } + else if (marks < 60 && marks >= 50) { + grade = 'B'; + } + else if (marks < 50 && marks >= 40) { + grade = 'C'; + } + else if (marks < 40 && marks >= 33) { + grade = 'D'; + } + else { + grade = 'F'; + } + return grade; + + + +} +const resetButton = document.getElementById('reset'); +resetButton.addEventListener('click', function () { + numberInput.value = '0'; + result.innerText = ' '; + removeErrormessage(); + +}); +function removeErrormessage() { + numberInput.classList.remove(ERROR_MESS); +} diff --git a/003-grade-calculator/Dipu/index.html b/003-grade-calculator/Dipu/index.html new file mode 100644 index 0000000..4ef51ea --- /dev/null +++ b/003-grade-calculator/Dipu/index.html @@ -0,0 +1,26 @@ + + + + + + Grade Calculator + + + + + +
+

Grade Calculator

+ + + + + + + +
+
+ + + + \ No newline at end of file