Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Interest Calculator</title>
    <link href=";500&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="style.css">
    <div class="container">
        <div class="input-wrapper">
            <div class="wrapper">
                <label for="principal">Principal($):</label>
                <input type="number" id="principal" value="1000" />
            <div class="wrapper">
               <label for="rate">Rate(%):</label>
               <input type="number" id="rate" value="5" /> 
        <label for="time">Time:</label>
        <div class="time-wrapper">
            <input type="number" id="time" value="1" />
            <select name="duration" id="duration">
                <option value="year">Year</option>
                <option value="month">Month</option>
        <button id="calculate-btn">Calculate </button>
        <div id="result"></div>
    <script src="script.js"></script>
  <div class="footer"><p>Created by <a href="" target="_blank">Richard Rembert</a></p>


    padding: 0;
    margin: 0;
    box-sizing: border-box;
    font-family: "Poppins", sans-serif;
    height: 100vh;
    background: linear-gradient(#8f01e2, #a872ff);
    background-color: #ffffff;
    position: absolute;
    transform: translate(-50%, -50%);
    top: 50%;
    left: 50%;
    width: 80vw;
    max-width: 600px;
    min-width: 350px;
    padding: 60px 30px;
    border-radius: 10px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    display: block;
    font-size: 22px;
    margin-bottom: 10px;
    font-weight: 500;
    margin-bottom: 20px;
    border: none;
    font-size: 20px;
    border-bottom: 2px solid #585858;
    color: #585858;
    padding: 2px 15px;
    outline: none;
    border-bottom: 2.4px solid #8f01e2;
    display: flex;
    justify-content: space-between;
    gap: 20px;
.input-wrapper input{
    width: 100%;
.time-wrapper input{
    width: 60%;
    width: 35%;
    border: 1px solid #585858;
    font-size: 20px;
    margin-left: 3%;
    padding: 8px 0;
    border-radius: 5px;
    display: block;
    background-color: #e28801;
    border: none;
    color: #ffffff;
    margin: 20px auto 0 auto;
    padding: 15px 40px;
    font-size: 20px;
    border-radius: 5px;
    background-color: #ffc772;
    margin-top: 30px;
    color: #585858;
    text-align: center;
    font-size: 18px;
    padding: 20px;
    border-radius: 5px;
#result div{
    margin-bottom: 10px;
#result span{
    color: #000000;
    font-weight: 500;
.footer {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 1rem;
    background-color: #fff;
    text-align: center;
.footer p {
  text-decoration: none;
  color: #000;
.footer a {
    text-decoration: none;
    color: #e28801;
.footer a:hover {
    text-decoration: underline;
    color: red;


                let calculateBtn = document.getElementById("calculate-btn");
let result = document.getElementById("result");
let calculate = () => {
    let p = Number(document.getElementById("principal").value);
    let r = Number(document.getElementById("rate").value);
    let t = Number(document.getElementById("time").value);
    let duration = document.getElementById("duration").value;
    let simpleInterest = 
    duration == "year" ? (p*r*t) / 100 : (p*r*t) / 1200;
    let amount = p + simpleInterest;

    result.innerHTML = `<div>Principal Amount: <span>$${p.toFixed(
        <div>Total Interest: <span>$${simpleInterest.toFixed(2)}</span></div>
        <div>Total Amount: <span>$${amount.toFixed(2)}</
calculateBtn.addEventListener("click", calculate);
window.addEventListener("load", calculate);