commit 772823c1deb1bfa354529f503e313ed425d0c2ce
Author: ejparnell <37162387+ejparnell@users.noreply.github.com>
Date: Mon Dec 10 10:26:42 2018 -0500
Add files via upload
diff --git a/Tip Calculator/README.md b/Tip Calculator/README.md
new file mode 100644
index 0000000..914ced8
Binary files /dev/null and b/Tip Calculator/README.md differ
diff --git a/Tip Calculator/calculator.js b/Tip Calculator/calculator.js
new file mode 100644
index 0000000..49b13fa
--- /dev/null
+++ b/Tip Calculator/calculator.js
@@ -0,0 +1,81 @@
+const tip10per = '10';
+const tip15per = '15';
+const tip20per = '20';
+
+// Function to create the original tip percent.
+function tipCalculator(billTotal, selectedPer) {
+ if (selectedPer === tip10per) {
+ return billTotal * .10;
+ }
+ else if (selectedPer === tip15per) {
+ return billTotal * .15;
+ }
+ else if (selectedPer === tip20per) {
+ return billTotal * .20;
+ }
+ throw new Error('tip not selected')
+}
+
+
+function totalAmount(billTotal, selectedPer, numPpl) {
+ //Gets the selected percent that you want to leave for a tip from the bill total enterd and adds them together.
+ let tipAmount = tipCalculator(billTotal, selectedPer);
+ let totalAmount = tipAmount + billTotal;
+ //Does the OCD calculations by rounding the total bill amount up to make a whole number. Then taking that number and subtracting it from the total bill, which gives you a new tip amount that makes the bill total to be a whole number.
+ let ocdTotalAmount = Math.ceil(totalAmount);
+ let ocdTipAmount = ocdTotalAmount - totalAmount;
+ let newTip = new Number(ocdTipAmount + tipAmount);
+
+ let billInfo = {
+ prevBillTotal: billTotal,
+ tipAmount: newTip,
+ newAmount: ocdTotalAmount
+ }
+ //Sends the above content to the splitBill function if more than one person was selected.
+ if (numPpl > 1) {
+ return splitBill(billInfo, numPpl);
+ }
+ else {
+ return billInfo;
+ }
+}
+
+function splitBill(splitTotal, numPpl) {
+ //Dividing the tip and bill between selected number of people.
+ let billPerPerson = splitTotal.prevBillTotal / numPpl;
+ let tipPerPerson = splitTotal.tipAmount / numPpl;
+ //Rounding bill to nearest 100 to make sure we get back a number that can be made from change.
+ tipPerPerson = Math.round(100 * tipPerPerson) / 100;
+
+ return {
+
+ prevBillTotal: splitTotal.prevBillTotal,
+ newAmount: billPerPerson,
+ tipAmount: tipPerPerson,
+ }
+}
+
+//Get the bill that is entered.
+function getTotalbill() {
+ return parseInt(document.getElementById('totalBillInput').value);
+}
+//Get the number of people entered.
+function getNumPpl() {
+ return parseInt(document.getElementById('numPplInput').value);
+}
+// Get the tip perect that was selected.
+function handlePercentClick(tipPercent) {
+ let billTotal = getTotalbill();
+ let numPpl = getNumPpl();
+
+ if (billTotal <= 0) {
+ return alert('Fill in all boxes please!')
+ }
+ else {
+ //Displays to the UI
+ let finBillTotal = totalAmount(billTotal, tipPercent, numPpl);
+ document.getElementById('ocdBill').textContent = finBillTotal.newAmount;
+ document.getElementById("ocdtTipAmount").textContent = finBillTotal.tipAmount;
+ }
+}
+
diff --git a/Tip Calculator/img/bg.jpeg b/Tip Calculator/img/bg.jpeg
new file mode 100644
index 0000000..de3e2a2
Binary files /dev/null and b/Tip Calculator/img/bg.jpeg differ
diff --git a/Tip Calculator/img/cardBG.jpeg b/Tip Calculator/img/cardBG.jpeg
new file mode 100644
index 0000000..bd15019
Binary files /dev/null and b/Tip Calculator/img/cardBG.jpeg differ
diff --git a/Tip Calculator/index.html b/Tip Calculator/index.html
new file mode 100644
index 0000000..6c6c669
--- /dev/null
+++ b/Tip Calculator/index.html
@@ -0,0 +1,50 @@
+
+
+
+