-
Part 1: Looping Calculations with Drag-and-Drop Feature
This page showcases the application of looping statements for performing calculations on specific integer sequences. A single do-while loop efficiently computes the sum and product of both every fourth integer from 5 to 25 and every third integer from 3 to 18, minimizing redundancy and optimizing the process. Results are dynamically generated and formatted using JavaScript's toLocaleString() for better readability. Additionally, an interactive, draggable element is included on the page, leveraging jQuery UI to provide a more engaging and responsive user experience.
-
Part 2: Compound Interest Calculation Tables
This page introduces compound interest calculations with three tables, each demonstrating growth over five years at different interest rates (5%, 6%, and 7%) on an initial principal of $1000. Using a nested loop, the script calculates the compound amount for each year, applying the formula A = P(1 + r)^n. Rows are styled with alternating colors for visual clarity, enhancing user readability without any input from the user. The page loads automatically, displaying the results in a clean, informative format.
-
Extra Credit: Hollow Square Pattern Generator
This part introduces a form where users can enter an integer between 2 and 10 to generate a hollow square pattern made of asterisks. Once a valid number is submitted, the webpage displays a hollow square of that size, ensuring only the borders are filled with asterisks while the inside remains empty. If an invalid input is provided, an error message appears instead of the pattern. The script uses nested loops to accurately display the pattern and handles form validation to guide users in inputting appropriate values.