postheadericon 23. Develop a interest calculation application in which user will provide all information in HTML form and that will be processed by servlet and response will be generated back to the user.



1. Using  Servlet

index.jsp


<html>
<head>
<title>EX-23</title>
<style>
.abc
{
background:#ababff;
position:absolute;
top:2in;
hieght:200px;
width:400px;
left:5in;
border-style:solid;
}
</style>

</head>
<body>

<div class="abc"  id="f1">
<br>
<form method="get" action="/Ex23/bipinrupadiya.blogspot.com">
<table align="center">
<tr>
<td colspan=2 align=center><h3>Simple Interest</h3><hr>
</td>
</tr>
<tr>
<td>Amount : </td>
<td><input type="text" name="p"></td>
</tr>
<tr>
<td>Rate :</td>
<td><input type="text" name="r"></td>
</tr>
<tr>
<td>Time :</td>
<td><input type="text" name="n"></td>
</tr>

<tr>
<td colspan=2 align=center>
<hr>
<input type="submit" value="Calculate">
<input type="reset" value="Clear">
</td>
</tr>
</table>
</form>
</div>
</body>
</html>


Ex23.java


package bsr;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.WebServlet;

/** Ex23 simple Interest. by Bipin S rupadiya */

@WebServlet("/bipinrupadiya.blogspot.com")
public class Ex23 extends HttpServlet
{
    public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
    {
        response.setContentType("text/html");
        PrintWriter out=response.getWriter();
     
        float p=Float.parseFloat(request.getParameter("p"));
        float r=Float.parseFloat(request.getParameter("r"));
        float n=Float.parseFloat(request.getParameter("n"));
        float i=(p*r*n)/100;
        out.println("<br><h1>Simple Interest will be : "+i);
    }
}



2. Using Java Beans (Form Beans)

index.jsp


<html>
<head>
<title>EX-23</title>
<style>
.abc
{
background:#ababff;
position:absolute;
top:2in;
hieght:200px;
width:400px;
left:5in;
border-style:solid;
}
</style>

</head>
<body>

<div class="abc"  id="f1">
<br>
<form method="POST" action="result.jsp">
<table align="center">
<tr>
<td colspan=2 align=center><h3>Simple Interest</h3><hr>
</td>
</tr>
<tr>
<td>Amount : </td>
<td><input type="text" name="p"></td>
</tr>
<tr>
<td>Rate :</td>
<td><input type="text" name="r"></td>
</tr>
<tr>
<td>Time :</td>
<td><input type="text" name="n"></td>
</tr>

<tr>
<td colspan=2 align=center>
<hr>
<input type="submit" value="Calculate">
<input type="reset" value="Clear">
</td>
</tr>
</table>
</form>
</div>
</body>
</html>



result.jsp


<html>
<head>
<title>EX-23</title>
<style>
.abc
{
background:#ababff;
position:absolute;
top:2in;
hieght:200px;
width:400px;
left:5in;
border-style:solid;
}
</style>

</head>
<BODY>
<CENTER>


<jsp:useBean id="si" class="bsr.SimpleIntrest" />

<jsp:setProperty name="si" property="*" />

<div class="abc"  id="f1">
<br>
<table width="50%" align="center">
<tr>
<th colspan=2><h3> Simple Interest</h3><hr></th>
</tr>
<tr>
<td>Amount : </td>
<td><jsp:getProperty name="si" property="p" /></td>
</tr>
<tr>
<td>Rate :</td>
<td><jsp:getProperty name="si" property="r" /></td>
</tr>
<tr>
<td>Time :</td>
<td><jsp:getProperty name="si" property="n" /></td>
</tr>
<tr>
<td>Interest :</td>
<td><jsp:getProperty name="si" property="intrest" /></td>
</tr>
<tr>
<th colspan=2> <hr><a href="index.jsp">Home</a></th>
</tr>
</table>
</form>
</div>
</body>
</html>



SimpleIntrest.java [ JavaBean ]


package bsr;
public class SimpleIntrest
{
private float p=1;
private float r=1;
private float n=1;

// Principal Amount
public float getP()
{
return(p);
}
public void setP(float v)
{
this.p = v;
}

// Rate of Interest
public float getR()
{
return(r);
}
public void setR(float v)
{
this.r = v;
}

// Number of Years
public float getN()
{
return(n);
}
public void setN(float v)
{
this.n = v;
}

//Calculate Interest
public float getIntrest()
{
return((p*r*n)/100);
}
}



6 comments:

kenwood said...

It's done quickly and cost-effectively. office 365

Huongkv said...

Aivivu đại lý vé máy bay, tham khảo

giá vé máy bay đi Mỹ khứ hồi

vé máy bay đi sài gòn

vé máy bay đi hà nội hạng thương gia

đi máy bay ra đà lạt

ve may bay gia re di quy nhon

taxi sân bay hà nội giá rẻ

combo đà lạt 3 ngày 2 đêm 2021

nayana said...

Hi, admin. Information that is unquestionably helpful. It helps me a lot that you shared. Please continue to update this useful information.
Colleges for BBA In Hyderabad

Harish said...

Hello, Administrator. Information that is really beneficial. I really appreciate what you gave. Please keep this helpful information updated.
Colleges In Hyderabad For B.com

Harish said...

This is an extremely interesting and educational post. keep on giving more information...
Best Colleges For BBA In Hyderabad



Harish said...

Hi, admin. Undoubtedly, this knowledge is helpful. Thank you very much for sharing this. Keep this type of useful information updated.Best Colleges For BBA In Hyderabad

Total Pageviews

© BipinRupadiya.com. Powered by Blogger.