From e13845e9afe14ea932ddb0d9aafb75cdd406fafa Mon Sep 17 00:00:00 2001 From: indrajeetyadav Date: Thu, 1 Aug 2024 01:09:59 +0530 Subject: [PATCH 1/6] discriminant Calculator Added --- Calculators/discriminant/index.html | 32 +++++++++ Calculators/discriminant/script.js | 35 ++++++++++ Calculators/discriminant/style.css | 101 ++++++++++++++++++++++++++++ index.html | 17 +++++ 4 files changed, 185 insertions(+) create mode 100644 Calculators/discriminant/index.html create mode 100644 Calculators/discriminant/script.js create mode 100644 Calculators/discriminant/style.css diff --git a/Calculators/discriminant/index.html b/Calculators/discriminant/index.html new file mode 100644 index 000000000..2b9e55da9 --- /dev/null +++ b/Calculators/discriminant/index.html @@ -0,0 +1,32 @@ + + + + + + + + Discriminant Calculator + + + +
+

DISCRIMINANT CALCULATOR

+ +

Please enter the coefficients a, b and c of a quadratic + equation of the form:
ax² + bx + c = 0

+ +
+ a = + b = + c = +
+
+ +

+

+ + +

+ + + \ No newline at end of file diff --git a/Calculators/discriminant/script.js b/Calculators/discriminant/script.js new file mode 100644 index 000000000..48f04fe75 --- /dev/null +++ b/Calculators/discriminant/script.js @@ -0,0 +1,35 @@ + +'use strict' + +function validate() { + // Get the input values + var a = parseFloat(document.forms["input_form"]["aterm"].value); + var b = parseFloat(document.forms["input_form"]["bterm"].value); + var c = parseFloat(document.forms["input_form"]["cterm"].value); + + var outputText, outputValue; + + // Validate the inputs + if (isNaN(a) || isNaN(b) || isNaN(c)) { + outputText = "All coefficients must be numbers!"; + } else if (a === 0) { + outputText = "a cannot be zero!"; + } else { + // Calculate the discriminant + var discriminant = Math.pow(b, 2) - 4 * a * c; + + outputText = "For the equation " + (a === 1 ? "" : a) + "x\u00B2 + " + (b === 1 ? "" : b) + "x + " + c + " = 0,"; + + if (discriminant > 0) { + outputValue = "The discriminant (D) is " + discriminant + ". There are two distinct real roots."; + } else if (discriminant === 0) { + outputValue = "The discriminant (D) is " + discriminant + ". There is exactly one real root."; + } else { + outputValue = "The discriminant (D) is " + discriminant + ". There are no real roots (complex roots)."; + } + } + + // Output the result + document.getElementById("output_text").innerHTML = outputText; + document.getElementById("outputValue").innerHTML = outputValue; +} \ No newline at end of file diff --git a/Calculators/discriminant/style.css b/Calculators/discriminant/style.css new file mode 100644 index 000000000..427c0ffb6 --- /dev/null +++ b/Calculators/discriminant/style.css @@ -0,0 +1,101 @@ +body { + font-family: 'Roboto', sans-serif; + margin: 0; + padding: 0; + background: linear-gradient(135deg, #3498db, #8e44ad); + background-size: cover; + color: #ecf0f1; + display: flex; + align-items: center; + justify-content: center; + height: 100vh; +} + +.container { + display: flex; + flex-direction: column; + width: 90%; + max-width: 400px; + background-color: rgba(255, 255, 255, 0.9); + padding: 20px; + border-radius: 8px; + box-shadow: 0 0 20px rgba(0, 0, 0, 0.2); +} + +h1 { + text-align: center; + color: #2ecc71; + margin-bottom: 20px; +} + +p { + text-align: center; + color: #6b6b6b; + margin: 10px 0; +} + +#equation { + font-size: 1.2rem; + margin-bottom: 20px; +} + +form { + text-align: center; + margin-top: 20px; + margin-bottom: 20px; + color: #6b6b6b; +} + +span { + display: inline-block; + margin: 0 10px; +} + +input { + font-size: 1rem; + padding: 10px; + margin: 0 10px 10px 10px; + border: 1px solid #ccc; + border-radius: 4px; + box-sizing: border-box; + transition: border-color 0.3s ease, box-shadow 0.3s ease; + color: #2c3e50; +} + +input:hover, +input:focus { + border-color: #3498db; +} + +form div { + margin-top: 20px; +} + +button { + background-color: #e74c3c; + color: #ecf0f1; + padding: 12px 24px; + border: none; + border-radius: 4px; + cursor: pointer; + transition: background-color 0.3s ease; + margin: 0 auto; + display: block; +} + +button:hover { + background-color: #c0392b; +} + +#output_text { + margin-top: 20px; + text-align: center; + color: #404040; +} + +#outputValue { + margin-top: 10px; + font-weight: bold; + font-size: 1.2em; + color: #2ecc71; +} \ No newline at end of file diff --git a/index.html b/index.html index 770b7ae8b..3e0d5da67 100644 --- a/index.html +++ b/index.html @@ -1541,6 +1541,23 @@

Checks the number is disarium or not and finds disarium numbers in a range.< + + // Added discriminant .... +
+
+

Discriminant Calculator

+

Calculates the Discriminant of a quadratic equation.

+ +
+
+

Discount Calculator

From 59b87c334c4fc1bd42b556652fdb2400885a5c34 Mon Sep 17 00:00:00 2001 From: Rakesh Roshan Date: Sat, 3 Aug 2024 19:51:14 +0530 Subject: [PATCH 2/6] Update and rename style.css to style.css --- Calculators/Discriminant-Calculator/style.css | 101 ++++++++++++++++++ Calculators/discriminant/style.css | 101 ------------------ 2 files changed, 101 insertions(+), 101 deletions(-) create mode 100644 Calculators/Discriminant-Calculator/style.css delete mode 100644 Calculators/discriminant/style.css diff --git a/Calculators/Discriminant-Calculator/style.css b/Calculators/Discriminant-Calculator/style.css new file mode 100644 index 000000000..ce8c4f73d --- /dev/null +++ b/Calculators/Discriminant-Calculator/style.css @@ -0,0 +1,101 @@ +body { + font-family: 'Roboto', sans-serif; + margin: 0; + padding: 0; + background: linear-gradient(135deg, #3498db, #8e44ad); + background-size: cover; + color: #ecf0f1; + display: flex; + align-items: center; + justify-content: center; + height: 100vh; +} + +.container { + display: flex; + flex-direction: column; + width: 90%; + max-width: 400px; + background-color: rgba(255, 255, 255, 0.9); + padding: 20px; + border-radius: 8px; + box-shadow: 0 0 20px rgba(0, 0, 0, 0.2); +} + +h1 { + text-align: center; + color: #2ecc71; + margin-bottom: 20px; +} + +p { + text-align: center; + color: #6b6b6b; + margin: 10px 0; +} + +#equation { + font-size: 1.2rem; + margin-bottom: 20px; +} + +form { + text-align: center; + margin-top: 20px; + margin-bottom: 20px; + color: #6b6b6b; +} + +span { + display: inline-block; + margin: 0 10px; +} + +input { + font-size: 1rem; + padding: 10px; + margin: 0 10px 10px 10px; + border: 1px solid #ccc; + border-radius: 4px; + box-sizing: border-box; + transition: border-color 0.3s ease, box-shadow 0.3s ease; + color: #2c3e50; +} + +input:hover, +input:focus { + border-color: #3498db; +} + +form div { + margin-top: 20px; +} + +button { + background-color: #e74c3c; + color: #ecf0f1; + padding: 12px 24px; + border: none; + border-radius: 4px; + cursor: pointer; + transition: background-color 0.3s ease; + margin: 0 auto; + display: block; +} + +button:hover { + background-color: #c0392b; +} + +#output_text { + margin-top: 20px; + text-align: center; + color: #404040; +} + +#outputValue { + margin-top: 10px; + font-weight: bold; + font-size: 1.2em; + color: #2ecc71; +} diff --git a/Calculators/discriminant/style.css b/Calculators/discriminant/style.css deleted file mode 100644 index 427c0ffb6..000000000 --- a/Calculators/discriminant/style.css +++ /dev/null @@ -1,101 +0,0 @@ -body { - font-family: 'Roboto', sans-serif; - margin: 0; - padding: 0; - background: linear-gradient(135deg, #3498db, #8e44ad); - background-size: cover; - color: #ecf0f1; - display: flex; - align-items: center; - justify-content: center; - height: 100vh; -} - -.container { - display: flex; - flex-direction: column; - width: 90%; - max-width: 400px; - background-color: rgba(255, 255, 255, 0.9); - padding: 20px; - border-radius: 8px; - box-shadow: 0 0 20px rgba(0, 0, 0, 0.2); -} - -h1 { - text-align: center; - color: #2ecc71; - margin-bottom: 20px; -} - -p { - text-align: center; - color: #6b6b6b; - margin: 10px 0; -} - -#equation { - font-size: 1.2rem; - margin-bottom: 20px; -} - -form { - text-align: center; - margin-top: 20px; - margin-bottom: 20px; - color: #6b6b6b; -} - -span { - display: inline-block; - margin: 0 10px; -} - -input { - font-size: 1rem; - padding: 10px; - margin: 0 10px 10px 10px; - border: 1px solid #ccc; - border-radius: 4px; - box-sizing: border-box; - transition: border-color 0.3s ease, box-shadow 0.3s ease; - color: #2c3e50; -} - -input:hover, -input:focus { - border-color: #3498db; -} - -form div { - margin-top: 20px; -} - -button { - background-color: #e74c3c; - color: #ecf0f1; - padding: 12px 24px; - border: none; - border-radius: 4px; - cursor: pointer; - transition: background-color 0.3s ease; - margin: 0 auto; - display: block; -} - -button:hover { - background-color: #c0392b; -} - -#output_text { - margin-top: 20px; - text-align: center; - color: #404040; -} - -#outputValue { - margin-top: 10px; - font-weight: bold; - font-size: 1.2em; - color: #2ecc71; -} \ No newline at end of file From 839790c35bc8f82a5f57083559bc2bd921f9feef Mon Sep 17 00:00:00 2001 From: Rakesh Roshan Date: Sat, 3 Aug 2024 19:51:34 +0530 Subject: [PATCH 3/6] Update and rename script.js to script.js --- .../{discriminant => Discriminant-Calculator}/script.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) rename Calculators/{discriminant => Discriminant-Calculator}/script.js (99%) diff --git a/Calculators/discriminant/script.js b/Calculators/Discriminant-Calculator/script.js similarity index 99% rename from Calculators/discriminant/script.js rename to Calculators/Discriminant-Calculator/script.js index 48f04fe75..4bbf08dd7 100644 --- a/Calculators/discriminant/script.js +++ b/Calculators/Discriminant-Calculator/script.js @@ -1,4 +1,3 @@ - 'use strict' function validate() { @@ -19,7 +18,7 @@ function validate() { var discriminant = Math.pow(b, 2) - 4 * a * c; outputText = "For the equation " + (a === 1 ? "" : a) + "x\u00B2 + " + (b === 1 ? "" : b) + "x + " + c + " = 0,"; - + if (discriminant > 0) { outputValue = "The discriminant (D) is " + discriminant + ". There are two distinct real roots."; } else if (discriminant === 0) { @@ -32,4 +31,4 @@ function validate() { // Output the result document.getElementById("output_text").innerHTML = outputText; document.getElementById("outputValue").innerHTML = outputValue; -} \ No newline at end of file +} From 57aa34a1d3eae9965fc479f884dd43299e596412 Mon Sep 17 00:00:00 2001 From: Rakesh Roshan Date: Sat, 3 Aug 2024 19:52:22 +0530 Subject: [PATCH 4/6] Rename index.html to index.html --- .../{discriminant => Discriminant-Calculator}/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Calculators/{discriminant => Discriminant-Calculator}/index.html (99%) diff --git a/Calculators/discriminant/index.html b/Calculators/Discriminant-Calculator/index.html similarity index 99% rename from Calculators/discriminant/index.html rename to Calculators/Discriminant-Calculator/index.html index 2b9e55da9..7bf7ec675 100644 --- a/Calculators/discriminant/index.html +++ b/Calculators/Discriminant-Calculator/index.html @@ -29,4 +29,4 @@

DISCRIMINANT CALCULATOR

- \ No newline at end of file + From 9ccd07347728bd0d18eef7564e6eb0a6a9ec843f Mon Sep 17 00:00:00 2001 From: Rakesh Roshan Date: Sat, 3 Aug 2024 19:55:32 +0530 Subject: [PATCH 5/6] Update index.html --- index.html | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index 3e0d5da67..254b470c8 100644 --- a/index.html +++ b/index.html @@ -1541,32 +1541,29 @@

Checks the number is disarium or not and finds disarium numbers in a range.<

- - // Added discriminant ....
-

Discriminant Calculator

-

Calculates the Discriminant of a quadratic equation.

+

Discount Calculator

+

Unlock Savings with Precision: Your Ultimate Discount Calculator.

-
-

Discount Calculator

-

Unlock Savings with Precision: Your Ultimate Discount Calculator.

+

Discriminant Calculator

+

Calculates the discriminant of a quadratic equation.

From 5326fe931dc7af479deb0d1546a4da9b6fe2f74d Mon Sep 17 00:00:00 2001 From: Rakesh Roshan Date: Sat, 3 Aug 2024 19:57:45 +0530 Subject: [PATCH 6/6] Create README.md --- Calculators/Discriminant-Calculator/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Calculators/Discriminant-Calculator/README.md diff --git a/Calculators/Discriminant-Calculator/README.md b/Calculators/Discriminant-Calculator/README.md new file mode 100644 index 000000000..aab3017b6 --- /dev/null +++ b/Calculators/Discriminant-Calculator/README.md @@ -0,0 +1,15 @@ +#

Discriminant Calculator

+ +## Description :- + +Calculates the discriminant of a quadratic equation. + +## Tech Stacks :- + +- HTML +- CSS +- JavaScript + +## Screenshots :- + +![image](https://github.com/user-attachments/assets/e88cb389-9de1-496b-8f40-6ce999d36a3c)