Java Practical Assignment Part B
Java Practical Assignment Part B
1. Create a JSP that receives marks of a exam of your subjects and display the result with
percentage and the result status for the same.
Total : __________
Percentage : __________
Result Status : __________ (Pass/Fail/First Class/Distinction etc)
Index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="result.jsp">
Enter Your Marks:
<br>
<br>
<strong>Advance Java:</strong><input type="text" name="AJ">
<br>
<br>
<strong>Advance Python:</strong><input type="text" name="AP">
<br>
<br>
<strong>ADA:</strong><input type="text" name="ADA">
<br>
<br>
<input type="submit">
</form>
</body>
</html>
Result.jsp
</body>
</html>
Input:
Output:
2. Create a JSP that receives a number n from the url and displays the following pattern
with highest number as n.
4
43
432
4321
Index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="result.jsp">
Enter a Range for Pattern:
<input type="text" name="range">
<input type="submit" >
</form>
</body>
</html>
result.jsp
out.println(str);
%>
</body>
</html>
Output:
Pattern for range: 4
4
43
432
4321
3. Create a servlet that receives a number n from the url and displays the following pattern
with highest number as n.
32123
32 23
3 3
Index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="result.jsp">
Enter a Range for Pattern:
<input type="text" name="range">
<input type="submit" >
</form>
</body>
</html>
result.jsp
for(int i = 1;i<=range;i++){
for(int j = range;j>=i;j--){
str += j;
}
for(int s=1;s<i;s++){
str += "*";
}
for(int m = 2;m<=range;m++){
str += (m);
}
str += "<br>";
}
out.println(str);
%>
</body>
</html>
Output:
32123
32*23
3**23
4. Create the following html form
Index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="result.jsp">
Loan Ammount:
<input type="text" name="amount">
<br>
<br>
Loan Period in Years:
<input type="text" name="years">
<br>
<br>
Interest Rate:
<input type="text" name="rate">
<br>
<br>
Total Installments:
<input type="radio" name="installment" value="12">12
<input type="radio" name="installment" value="6">6
<input type="radio" name="installment" value="4">4
<input type="radio" name="installment" value="3">3
<input type="radio" name="installment" value="2">2
<input type="radio" name="installment" value="1">1
<br>
<br>
<input type="submit">
</form>
</body>
</html>
result.jsp
double rate =
Double.parseDouble(request.getParameter("rate"))/(12*100);
out.println("Interest Rate: " + request.getParameter("rate") +
"<br>");
%>
</body>
</html>
Input:
Output:
Loan Ammount: 1200
Loan Periods in years: 3
Interest Rate: 20
Total Installments: 18
Installments per year: 6
Installment Ammount: 77.71584072721494
Total Ammount to be paid: 1398.885133089869