How to make Simple interest & compund interest calculator in Java?



Mathematical calculation becomes complex especially during simple interest and compound interest. Simple interest is the product of principal,rate and time divided by 100. However the compound interest the formula is different. In this project we are using Bootstrap, Java scripts skills.

  • First of all open notepad and paste the following code

<html>
<head>
<title>How to make Simple interest & compund interest calcultor in Java?</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container bg-primary">
<h2 class="text-center">How to make Simple interest & compund interest calcultor in Java?</h2>
 <div class="form-group">
    <label for="principal">Principal:</label>
    <input type="email" class="form-control" id="principal">
  </div>
  <div class="form-group">
    <label for="time">Time:</label>
    <input type="text" class="form-control" id="time">
  </div>
  <div class="form-group">
    <label for="time">Rate:</label>
    <input type="text" class="form-control" id="rate">
  </div>
<button type="submit" class="btn btn-warning" onclick = "simple_interest()">Submit</button>
<div id="num"> </div>
<div id="num1"></div>
<div id="num2"></div>
</form>
</div>


</div>
</body>

<script type="text/javascript">
function simple_interest()
{
var p,t,r,si,ci;
p = document.getElementById ("principal").value;
t = document.getElementById ("time").value;
r = document.getElementById ("rate").value;
si = parseInt((p*t*r)/100 );
amount = p*Math.pow((1 +r/100),t );
ci = amount-p;
diff=ci-si;
document.getElementById ('num').innerHTML ="Simple interest : "+si;
document.getElementById ('num1').innerHTML ="Compound interest : "+ci;
document.getElementById ('num2').innerHTML ="Difference between compound interest and simple interest : "+diff;
}
</script>
</html>

  • Now save this file as interestcalculator.html 
  • Open this file in browser and you can check the web application that can calculate the simple interest, compund interest and the difference between compound and simple interest.
  • Fill up the text box and find the output results simultaneously in one click.
Contact us in case you are looking for Java developers or Java programmers for Java software development or Java application development. Technoligent is the best Java software development company that has dedicated Java development team for Java projects.

Also check our blog


👉5 things to look while choosing java web development company

Post a Comment

Previous Post Next Post

Contact Form