Search:

Submit Article

From an insurance company a person takes a policy of 1 lakh rupees. If he takes this insurance for 25 years he has to pay a premium of Rs.4000/year

Posted By: Milind Mishra     Category: OOAD     Views: 1766

Code for From an insurance company a person takes a policy of 1 lakh rupees. If he takes this insurance for 25 years he has to pay a premium of Rs.4000/year in OOAD

```// premium.html

<html>
<body>
Enter Name of the person : <input type="text" name="person_name">

<br>
<br>

Select no. of years:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
<select name="num_years">
<option value="25years" selected>25 years </option>
<option value="30years"> 30 years </option>
</select>
<br>
<br>
Select criteria :&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
<select name="criteria">
<option value="working_male">Working Male </option>
</select>
<br>
<br>

</form>
</body> </html>

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

{

publicvoid doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{

try
{

String name_of_person="";
String years="";
String criteria="";
double prem_val=0;
name_of_person = req.getParameter("person_name");
years = req.getParameter("num_years");
criteria=req.getParameter("criteria");

{
if(years.equals("25years"))
{
PrintWriter out = res.getWriter();
out.println("Premium to be paid by "+name_of_person+" is Rs 4000/year");
out.close(); //Close the output stream
}

elseif(years.equals("30years"))
{
PrintWriter out = res.getWriter();
out.println("Premium to be paid by "+name_of_person+" is Rs 3000/year");
out.close(); //Close the output stream
}
}
{
if(years.equals("25years"))
{
PrintWriter out = res.getWriter();
prem_val=4000-((5*4000)/100);
out.println("Premium to be paid by "+name_of_person+" is Rs "+prem_val+"/year");
out.close(); //Close the output stream
}

elseif(years.equals("30years"))
{
PrintWriter out = res.getWriter();
prem_val=3000-((5*3000)/100);
out.println("Premium to be paid by "+name_of_person+" is Rs "+prem_val+"/year");
out.close(); //Close the output stream
}
}

}
catch (Exception e)
{  System.out.println("Error " + e);
}
}
}

// OUTPUT

(1)

------------------------
ON HTML FORM INPUTS ARE:
------------------------
Enter Name of the person :  dharini modi

Select no. of years: 25 years

---------
RESPONSE
---------
Premium to be paid by  dharini modi is Rs 4000/year

(2)

------------------------
ON HTML FORM INPUTS ARE:
------------------------
Enter Name of the person :   dharini modi

Select no. of years: 30 years

---------
RESPONSE
---------
Premium to be paid by  dharini modi is Rs 2850.0/year

(2)

------------------------
ON HTML FORM INPUTS ARE:
------------------------
Enter Name of the person :  dharini modi

Select no. of years: 25 years

---------
RESPONSE
---------
Premium to be paid by  dharini modi is Rs 3800.0/year

(4)

------------------------
ON HTML FORM INPUTS ARE:
------------------------
Enter Name of the person :  ashvin modi

Select no. of years: 30 years

Select criteria : Working male
---------
RESPONSE
---------
Premium to be paid by ashvin modi is Rs 3000/year

```
Share:

 Milind Mishra author of From an insurance company a person takes a policy of 1 lakh rupees. If he takes this insurance for 25 years he has to pay a premium of Rs.4000/year is from India. View All Articles

 Please enter your CommentComment should be atleast 30 Characters.Please put code inside [Code] your code [/Code]. No Comment Found, Be the First to post comment!