From b67e47af68b58e279331e578bb8145c892a9f3ab Mon Sep 17 00:00:00 2001
From: Archit Shukla <95583743+Archit-Ash@users.noreply.github.com>
Date: Tue, 28 May 2024 00:20:12 +0530
Subject: [PATCH] Added Tip Calculator (#913)
---
Calculators/Tip-Calculator/README.md | 15 ++++++++
Calculators/Tip-Calculator/index.html | 28 +++++++++++++++
Calculators/Tip-Calculator/script.js | 27 +++++++++++++++
Calculators/Tip-Calculator/style.css | 49 +++++++++++++++++++++++++++
index.html | 14 ++++++++
5 files changed, 133 insertions(+)
create mode 100644 Calculators/Tip-Calculator/README.md
create mode 100644 Calculators/Tip-Calculator/index.html
create mode 100644 Calculators/Tip-Calculator/script.js
create mode 100644 Calculators/Tip-Calculator/style.css
diff --git a/Calculators/Tip-Calculator/README.md b/Calculators/Tip-Calculator/README.md
new file mode 100644
index 000000000..48c853e12
--- /dev/null
+++ b/Calculators/Tip-Calculator/README.md
@@ -0,0 +1,15 @@
+#
Tip Calculator
+
+## Description :-
+
+Calculates the tip amount and final amount on the basis of tip percentage and bill amount.
+
+## Tech Stacks :-
+
+- HTML
+- CSS
+- JavaScript
+
+## Screenshots :-
+
+![image](https://github.com/Rakesh9100/CalcDiverse/assets/73993775/d192fc57-906c-4858-8748-ade21471015f)
diff --git a/Calculators/Tip-Calculator/index.html b/Calculators/Tip-Calculator/index.html
new file mode 100644
index 000000000..ed8d5b1c4
--- /dev/null
+++ b/Calculators/Tip-Calculator/index.html
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+ Tip Calculator
+
+
+
+
+
+
+
+
diff --git a/Calculators/Tip-Calculator/script.js b/Calculators/Tip-Calculator/script.js
new file mode 100644
index 000000000..493e6d894
--- /dev/null
+++ b/Calculators/Tip-Calculator/script.js
@@ -0,0 +1,27 @@
+function calculateTip() {
+ var billAmount = parseFloat(document.getElementById("billAmount").value);
+ var tipPercentage = parseFloat(
+ document.getElementById("tipPercentage").value
+ );
+
+ if (
+ isNaN(billAmount) ||
+ isNaN(tipPercentage) ||
+ billAmount < 0 ||
+ tipPercentage < 0
+ ) {
+ alert("Please enter valid numbers.");
+ return;
+ }
+ // checks for blank inputs
+
+ var tipAmount = (billAmount * tipPercentage) / 100; // calculates the tip amount
+ var totalAmount = billAmount + tipAmount; // calculate the total amount
+
+ document.getElementById(
+ "tipAmount"
+ ).textContent = `Tip Amount: ₹${tipAmount.toFixed(2)}`;
+ document.getElementById(
+ "totalAmount"
+ ).textContent = `Total Amount (including tip): ₹${totalAmount.toFixed(2)}`;
+}
diff --git a/Calculators/Tip-Calculator/style.css b/Calculators/Tip-Calculator/style.css
new file mode 100644
index 000000000..afc1df5ba
--- /dev/null
+++ b/Calculators/Tip-Calculator/style.css
@@ -0,0 +1,49 @@
+body {
+ font-family: cursive;
+ background: rgb(238, 174, 202);
+ background: radial-gradient(circle,
+ rgba(238, 174, 202, 1) 0%,
+ rgba(148, 187, 233, 1) 100%);
+ height: 100vh;
+ margin: 0;
+}
+
+header {
+ display: block;
+ text-align: center;
+ margin-bottom: 20px;
+ vertical-align: middle;
+}
+
+#container {
+ margin-top: 10vh;
+}
+
+#calculator {
+ margin: auto;
+ width: 500px;
+ padding: 30px;
+ border: 1px solid;
+ border-radius: 5px;
+ background-color: cyan;
+ text-align: center;
+}
+
+input[type="number"],
+button {
+ width: 100%;
+ padding: 20px;
+ margin-bottom: 10px;
+ box-sizing: border-box;
+}
+
+button {
+ background-color: #007bff;
+ color: #fff;
+ border: none;
+ cursor: pointer;
+}
+
+button:hover {
+ background-color: #002f61;
+}
diff --git a/index.html b/index.html
index 974657f14..de31285e4 100644
--- a/index.html
+++ b/index.html
@@ -2078,6 +2078,20 @@ Instantly find the time difference anywhere in the world.
+
+
+
Tip Calculator
+ Calculates the tip amount and final amount based on tip percentage and amount.
+
+
+