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 @@ + + + + + Tip calculator + + + + + + + + + +
+
+

+ Tip Calculator +

+
+
+ +
+ +
+
+ + + +
+ +
+
+ +
+
+ +
+
+

OCD Bill (per person):

+
+
+

OCD Tip Amount (per person):

+
+
+ +
+ + + \ No newline at end of file diff --git a/Tip Calculator/main.css b/Tip Calculator/main.css new file mode 100644 index 0000000..9e9b9a8 --- /dev/null +++ b/Tip Calculator/main.css @@ -0,0 +1,68 @@ +@import url("https://fonts.googleapis.com/css?family=Ubuntu"); +body { + margin: 0; + font-family: 'Ubuntu'; +} + +.inputCard { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -ms-flex-direction: column; + flex-direction: column; + -webkit-clip-path: polygon(0% 0%, 100% 0, 100% 36%, 50% 64%, 0 36%); + clip-path: polygon(0% 0%, 100% 0, 100% 36%, 50% 64%, 0 36%); + background-color: #c60de2; + width: 100%; + height: 100%; + position: absolute; + z-index: -1; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.inputCard h1 { + margin: 0; + font-size: 3.5rem; + margin-bottom: 1rem; +} + +.inputCard label { + font-size: 2rem; +} + +.inputCard .billInput { + width: 75vw; + margin-bottom: 1rem; + font-size: 1.5rem; +} + +.inputCard .tipPer { + font-size: 2.5rem; + margin-bottom: 1rem; +} + +.inputCard .split { + font-size: 1.5rem; + width: 15vw; +} + +.resultCard { + position: fixed; + bottom: .5rem; + width: 100vw; + margin-left: .5rem; + margin-right: .5rem; +} + +.resultCard .bottomH2 { + margin-bottom: 0; +} + +.resultCard span { + font-size: 1.5em; +} +/*# sourceMappingURL=main.css.map */ \ No newline at end of file diff --git a/Tip Calculator/main.css.map b/Tip Calculator/main.css.map new file mode 100644 index 0000000..2dcdd8e --- /dev/null +++ b/Tip Calculator/main.css.map @@ -0,0 +1,9 @@ +{ + "version": 3, + "mappings": "AAAA,OAAO,CAAC,qDAAI;AAUZ,AAAA,IAAI,CAAC;EACD,MAAM,EAAE,CAAC;EACT,WAAW,EAAE,QAAQ;CACxB;;AAGD,AAAA,UAAU,CAAC;EACP,OAAO,EAAE,IAAI;EACb,cAAc,EAAE,MAAM;EACtB,SAAS,EAAE,gDAAgD;EAC3D,gBAAgB,EAjBP,OAAO;EAkBhB,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,IAAI;EACZ,QAAQ,EAAE,QAAQ;EAClB,OAAO,EAAE,EAAE;EACX,WAAW,EAAE,MAAM;CA2BtB;;AApCD,AAWI,UAXM,CAWN,EAAE,CAAC;EACH,MAAM,EAAE,CAAC;EACT,SAAS,EAAE,MAAM;EACjB,aAAa,EAAE,IAAI;CAClB;;AAfL,AAiBI,UAjBM,CAiBN,KAAK,CAAC;EACF,SAAS,EAAE,IAAI;CAClB;;AAnBL,AAqBI,UArBM,CAqBN,UAAU,CAAC;EACP,KAAK,EAAE,IAAI;EACX,aAAa,EAAE,IAAI;EACnB,SAAS,EAAE,MAAM;CACpB;;AAzBL,AA2BI,UA3BM,CA2BN,OAAO,CAAC;EACJ,SAAS,EAAE,MAAM;EACjB,aAAa,EAAE,IAAI;CACtB;;AA9BL,AAgCI,UAhCM,CAgCN,MAAM,CAAC;EACH,SAAS,EAAE,MAAM;EACjB,KAAK,EAAE,IAAI;CACd;;AAGL,AAAA,WAAW,CAAC;EACR,QAAQ,EAAE,KAAK;EACf,MAAM,EAAE,KAAK;EACb,KAAK,EAAE,KAAK;EACZ,WAAW,EAAE,KAAK;EAClB,YAAY,EAAE,KAAK;CAStB;;AAdD,AAOI,WAPO,CAOP,SAAS,CAAC;EACN,aAAa,EAAE,CAAC;CACnB;;AATL,AAWI,WAXO,CAWP,IAAI,CAAC;EACD,SAAS,EAAE,KACf;CAAC", + "sources": [ + "main.scss" + ], + "names": [], + "file": "main.css" +} \ No newline at end of file diff --git a/Tip Calculator/main.scss b/Tip Calculator/main.scss new file mode 100644 index 0000000..bffb60f --- /dev/null +++ b/Tip Calculator/main.scss @@ -0,0 +1,69 @@ +@import url('https://fonts.googleapis.com/css?family=Ubuntu'); + +$colors: ( + primary: #c60de2, +); + +@function color($color-name) { + @return map-get($colors, $color-name) +} + +body { + margin: 0; + font-family: 'Ubuntu'; +} + + +.inputCard { + display: flex; + flex-direction: column; + clip-path: polygon(0% 0%, 100% 0, 100% 36%, 50% 64%, 0 36%); + background-color: color(primary); + width: 100%; + height: 100%; + position: absolute; + z-index: -1; + align-items: center; + + h1 { + margin: 0; + font-size: 3.5rem; + margin-bottom: 1rem; + } + + label { + font-size: 2rem; + } + + .billInput { + width: 75vw; + margin-bottom: 1rem; + font-size: 1.5rem; + } + + .tipPer { + font-size: 2.5rem; + margin-bottom: 1rem; + } + + .split { + font-size: 1.5rem; + width: 15vw; + } +} + +.resultCard { + position: fixed; + bottom: .5rem; + width: 100vw; + margin-left: .5rem; + margin-right: .5rem; + + .bottomH2 { + margin-bottom: 0; + } + + span { + font-size: 1.5em + } +} \ No newline at end of file