Search This Blog

Saturday, 15 September 2012

Practical 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.


Fileneme-interestcall.jsp

<html>
<body>
<form action="http://localhost:8090/wtad/CalInterest">
Principle Amount
<input type="text" name="pm"/>
<br>
Rate of Amount
<input type="text" name="rm"/>
<br>
Time period
<input type="text" name="tm"/>
<br>
<input type="submit" name="sub"/>
</form>
</body>
</html>


Filename-Callinterest.java

package def23;
import java.io.*;
import java.util.*;
import javax.servlet.http.*;
import javax.servlet.*;

public class CalInterest extends HttpServlet
{
          public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException,ServletException
          {
                   res.setContentType("Text/html");
                   PrintWriter out=res.getWriter();
                   out.println("CAll Interst is call");

                   int pamt=Integer.parseInt(req.getParameter("pm"));
                   int ramt=Integer.parseInt(req.getParameter("rm"));
                   int tamt=Integer.parseInt(req.getParameter("tm"));

                   double i;
                   i=(pamt*ramt*tamt)/100;

                   out.println("<br>"+"Interest is="+i);

          }
}

Output

Filename-23interestcal.html

Principle Amount  
Rate of Amount  
Time period  

Filename-CalInterest.java
CAll Interst is call 
Interest is=6.0

No comments:

Post a Comment