Mini Project - Simple Interest Calculator using HTML BOOTSTRAP JAVASCRIPT

Mini Project - Simple Interest Calculator using HTML BOOTSTRAP JAVASCRIPT

Creating a simple interest calculator using HTML, Bootstrap, and JavaScript involves using Bootstrap for styling and layout, HTML for the structure, and JavaScript for the functionality.

Here's how to build it:

1. HTML

Create the structure of the form with Bootstrap classes for styling.

2. JavaScript

Add the functionality to calculate the simple interest and display the result.

Program Code

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Simple Interest Calculator</title>
    <link  rel="stylesheet">
</head>

<body>
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-6">
                <div class="card mt-5">
                    <div class="card-header text-center">
                        <h2>Simple Interest Calculator</h2>
                    </div>
                    <div class="card-body">
                        <form id="interestForm">
                            <div class="form-group">
                                <label for="principal">Principal Amount:</label>
                                <input type="number" class="form-control" id="principal" name="principal" required>
                            </div>
                            <div class="form-group">
                                <label for="rate">Rate of Interest (% per year):</label>
                                <input type="number" class="form-control" id="rate" name="rate" step="0.01" required>
                            </div>
                            <div class="form-group">
                                <label for="time">Time (years):</label>
                                <input type="number" class="form-control" id="time" name="time" required>
                            </div>
                            <button type="button" class="btn btn-danger btn-block"
                                onclick="calculateInterest()">Calculate</button>
                        </form>
                        <div id="result" class="mt-4"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
    <script>
        function calculateInterest() {
            // Get the values from the form
            const principal = parseFloat(document.getElementById('principal').value);
            const rate = parseFloat(document.getElementById('rate').value);
            const time = parseFloat(document.getElementById('time').value);

            // Calculate the simple interest
            const interest = (principal * rate * time) / 100;

            // Display the result
            document.getElementById('result').innerHTML = `<div class="alert alert-info">Simple Interest: RS - ${interest.toFixed(2)}</div>`;
        }

    </script>
</body>

</html>        


要查看或添加评论,请登录

Sridhar Raj P的更多文章

  • Lists and Keys in React JS

    Lists and Keys in React JS

    In React, we use lists to render multiple components dynamically, and keys help React identify which items have…

    1 条评论
  • Object State Management

    Object State Management

    Object State Management Managing object state with in React is common when handling complex data structures like user…

  • useState Example

    useState Example

    Here are examples of using the hook in React functional components. Each example demonstrates a different use case.

  • Examples of using the useState hook in React Functional Components

    Examples of using the useState hook in React Functional Components

    Examples of using the useState hook in React Functional Components 1. Counter Example - ? Basic counter with increment…

  • Array, Array of Objects Values using Functional Component

    Array, Array of Objects Values using Functional Component

    Example 1: Displaying an Array of Strings import React from react; const FruitsList = () = { const fruits = [Apple…

    1 条评论
  • Hooks

    Hooks

    What are Hooks in React JS? Hooks in React allow functional components to manage state and side effects, which were…

  • State in Functional Components (useState Hook)

    State in Functional Components (useState Hook)

    State in Functional Components (useState Hook) In functional components, state is managed using the hook instead of and…

  • React State in Class Component

    React State in Class Component

    React State In React, state is used to store and manage component-specific data that can change over time. Unlike…

  • React JS Props

    React JS Props

    React JS Props (Properties) Props (short for "properties") in React are used to pass data from one component to…

  • Employee Management System - JSON Server

    Employee Management System - JSON Server

    A simple Employee Management System using React JS Hooks. It includes CRUD operations (Create, Read, Update, Delete)…

社区洞察

其他会员也浏览了