CALCULATE
INCOMETAX
<%@ page language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1">
<title>Calculate Interest JSP</title>
</head>
<body>
<%
String fname =
request.getParameter("fname");
String lname =
request.getParameter("lname");
String gender = request.getParameter("gender");
String profession =
request.getParameter("profession");
String prefix = " ";
if (gender.equals("Male")) { prefix =
"Mr."; }
else if (gender.equals("Female")) { prefix
= "Ms."; } %>
<FONT COLOR = "Blue">Hello
<%=prefix %> <%=fname%> <%=lname%>
who works in a <%=profession %></FONT>
<% String sincome =
request.getParameter("income");
float income = Float.parseFloat(sincome);
out.println("<BR>Your Annual Income is
<FONT COLOR = Blue> " +income + "</FONT>");
float tax;
float diff;
if(income <= 100000)
{
out.println("<BR>You are below the Tax
Bracket!!");
}
else if(income >100000 && income <=
200000)
{
out.println("<BR>Your Tax Bracket is
between Rs.1,00000 to Rs.2,00000");
out.println("<BR><B><U> Tax
Rule: </U></B>10% of income above Rs.1 Lakh");
diff = income - 100000;
tax = (float)0.1*diff;
out.println("<BR>Tax to be paid is
<FONT COLOR = Blue> "+tax+ "</FONT>");
}
else if(income >200000 && income <=
300000)
{
out.println("<BR>Your Tax Bracket is
between between Rs.1,00000 to Rs.3,00000");
out.println("<BR><B><U>Tax
Rule: </U></B> 10% of income upto Rs.1 Lakh and 20% of rest of
income");
diff = income - 200000;
tax = (float)0.2*diff + (float)0.1*100000;
out.println("<BR>Tax to be paid is
<FONT COLOR = Blue> "+tax+ "</FONT>");
}
else if(income >100000 && income <=
400000)
{
out.println("<BR>Your Tax Bracket is
between Rs.1,00000 to Rs.4,00000");
out.println("<BR><B><U>Tax
Rule: </U></B>10% of income upto Rs.1 Lakh 20% of income upto Rs.3
Lakh and 30% of rest of income");
diff = income - 300000;
tax = (float)0.3*diff + (float)0.2*200000 +
(float)0.1*100000;
out.println("<BR>Tax to be paid is
<FONT COLOR = Blue> "+tax);
}
else if(income > 400000)
{
out.println("<BR>You fall in the tax
bracket greater than Rs.4,00000");
diff = income - 400000;
tax = diff + (float)0.3*300000 + (float)0.2*200000 +
(float)0.1*100000;
out.println("<BR><B><U>Tax
Rule:</U></B> 10% of income upto Rs.1 Lakh 20% of income upto
3Lakh, 30% of income upto Rs.4 lakh and 100% of rest of income");
out.println("<BR>Tax to be paid is
<FONT COLOR = Blue> "+tax+ "</FONT>");
}//end if %>
</body>
</html>
DATA
CAPTURE
<%@ page language="java"
contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"
import = "java.util.* , java.text.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%!
HashMap hm;
String uname;
String pwd;
Map.Entry entry;
%>
<%
boolean login = false;
hm = new HashMap();
uname = request.getParameter("username");
pwd = request.getParameter("password");
hm.put("Archie","Riverdale");
hm.put("Haddock",
"Marlinspike");
hm.put("Hermione","Hogwarts");
Set s = hm.entrySet();
Iterator it = s.iterator();
while(it.hasNext())
{
entry = (Map.Entry) it.next();
if(uname.equals(entry.getKey()) &&
pwd.equals(entry.getValue()))
{
login=true;
}
}//end while
if(login==true)
{
out.println("<B><FONT COLOR =
Blue>");
out.println("Welcome
</FONT></B>");
out.println(uname);
DateFormat dateFormat = new
SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date();
out.println("<BR><FONT COLOR =
Green>");
out.println("Today is
</FONT>"+dateFormat.format(date));
%>
<form action="CalculateInterest.jsp"
method = "post">
<FONT COLOR = "Magenta"> First
Name:</FONT>
<input type = "text" size =
"15" name = "fname">
<br>
<FONT COLOR = "Brown">Last Name:
</FONT>
<input type = "text" size =
"15" name = "lname">
<br>
<FONT COLOR = "Purple">Select your
Place of Work:</FONT>
<br>
<select name="profession"
size="3">
<option>IT Company</option>
<option>Private Bank</option>
<option>Insurance
Company</option>
</select>
<br>
<input type="radio"
name="gender" value="Male"> Male<br>
<input type="radio"
name="gender" value="Female" checked>Female<br>
<br>
<FONT COLOR = "Red"> Annual
Income(in Rupees):</FONT>
<input type = "text" size =
"15" name = "income">
<br>
<br>
<input type = "submit" value =
"Calculate Tax">
</form>
<%
}
else
{
%>
<jsp:forward page="Login.jsp">
<jsp:param name="FailReason" value="Wrong Username or
Password"/>
</jsp:forward>
<%
}
%>
</body>
</html>
LOGIN
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1">
<title>Login Page</title>
</head>
<body>
<form action="dataCapture.jsp" method =
"post">
User Name:
<input type = "text" size =
"15" name = "username">
<br>
Password:
<input type = "password" size =
"15" name = "password">
<br>
<input type = "submit" value =
"Login">
</form>
<%
String reason =
request.getParameter("FailReason");
if(reason !=null)
out.println(reason); %>
</body>
</html>