diff --git a/README.md b/README.md deleted file mode 100644 index 170b955..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -# fee-calculator \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..2534e01 --- /dev/null +++ b/index.html @@ -0,0 +1,48 @@ + + + + + + + Membership Fee Calculator + + + +

Calculate Your Membership Fee

+
+
+ Membership Details + +
+ +
+ +
+ +
+ +
+

+

+
+ + + diff --git a/script.js b/script.js new file mode 100644 index 0000000..495d2f0 --- /dev/null +++ b/script.js @@ -0,0 +1,58 @@ +function calculateFee() { + const attendingLeague = document.getElementById("attendingLeague").value; + const sprintFlown = document.getElementById("sprintFlown").checked; + const xcFlown = document.getElementById("xcFlown").checked; + const firstSprint = document.getElementById("firstSprint").checked; + const firstXc = document.getElementById("firstXc").checked; + + const membershipFee = getMembershipFee( + attendingLeague, + sprintFlown, + xcFlown, + firstSprint, + firstXc + ); + document.getElementById( + "membershipFee" + ).textContent = `Your membership fee is: $${membershipFee}`; +} + +function getMembershipFee(attendingLeague, sprintFlown, xcFlown, firstSprint = true, firstXc = true) { + // First-time Sprint is free + if (attendingLeague === "Sprint" && !sprintFlown) { + return 0; + } + + // First-time XC without Sprint is $25 + if (attendingLeague === "XC" && !xcFlown && !sprintFlown) { + return 25; + } + + // Sprint only or Both leagues with Sprint flown but not XC + if ((attendingLeague === "Sprint" || (attendingLeague === "Both" && sprintFlown && !xcFlown)) && firstSprint) { + return 25; + } + + // XC only or Both leagues with both flown before + if (attendingLeague === "XC" || (attendingLeague === "Both" && sprintFlown && xcFlown)) { + return 50; + } + + // Late Sprint renewal is $40 + if (attendingLeague === "Sprint" && !firstSprint) { + return 40; + } + + // Late XC renewal is $75 + if (attendingLeague === "XC" && !firstXc) { + return 75; + } + + // Default case, if none of the above conditions are met + return 50; +} + + +document.getElementById('membershipForm').addEventListener('change', calculateFee); + +calculateFee(); \ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..83031a3 --- /dev/null +++ b/style.css @@ -0,0 +1,25 @@ +body { + font-family: sans-serif; + margin: 40px; +} + +fieldset { + border: 1px solid #ccc; + padding: 15px; + margin-bottom: 20px; +} + +legend { + font-weight: bold; + padding: 5px; +} + +label { + display: block; + margin-bottom: 5px; +} + +#membershipFee { + font-weight: bold; + margin-top: 15px; +}