0% found this document useful (0 votes)
60 views

Java Practical Assignment Part B

The document describes 4 Java practical assignments: 1. A JSP that takes exam marks as input and displays total, percentage, and result. 2. A JSP that takes a number and displays a descending number pattern of that length. 3. A servlet that takes a number and displays an ascending/descending number pattern. 4. An HTML form that takes loan details as input and calculates installments.

Uploaded by

Sahil Chauahan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Java Practical Assignment Part B

The document describes 4 Java practical assignments: 1. A JSP that takes exam marks as input and displays total, percentage, and result. 2. A JSP that takes a number and displays a descending number pattern of that length. 3. A servlet that takes a number and displays an ascending/descending number pattern. 4. An HTML form that takes loan details as input and calculates installments.

Uploaded by

Sahil Chauahan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

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.

Advance Java (AJ) : __________


Advance Python (AP) : __________
ADA : __________

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

<%@ page language="java" contentType="text/html; charset=UTF-8"


pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
int AJ = Integer.parseInt( request.getParameter("AJ"));
int AP = Integer.parseInt( request.getParameter("AP"));
int ADA = Integer.parseInt( request.getParameter("ADA"));

int total = AJ + AP + ADA;

double pr = (total * 100)/300;

out.println("Total Marks: " + total);

out.println("Percentage: " + pr +"%");

out.print("Result Status: ");

if(pr >= 80){


out.println("Distinctioin");
}else if(pr>=60){
out.println("First Class");
}
else if(pr >= 40){
out.println("Pass");
}
else{
out.println("Fail");
}
%>

</body>
</html>

Input:
Output:

Total Marks: 130


Percentage: 43.0%
Result Status: Pass

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

<%@ page language="java" contentType="text/html; charset=UTF-8"


pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%

int range = Integer.parseInt(request.getParameter("range"));

String str = "";


out.println("Pattern for range: " + range + "<br>");
for(int i = 1; i<=range;i++){
for(int j = 0;j<i;j++){
str += (range-j);
}
str+= "<br>";
}

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

<%@ page language="java" contentType="text/html; charset=UTF-8"


pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%

int range = Integer.parseInt(request.getParameter("range"));

String str = "";

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

<%@ page language="java" contentType="text/html; charset=UTF-8"


pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%

int amount = Integer.parseInt(request.getParameter("amount"));


out.println("Loan Ammount: " + amount + "<br>");

int years = Integer.parseInt(request.getParameter("years"));


out.println("Loan Periods in years: " + years + "<br>");

double rate =
Double.parseDouble(request.getParameter("rate"))/(12*100);
out.println("Interest Rate: " + request.getParameter("rate") +
"<br>");

int ins = Integer.parseInt(request.getParameter("installment"));

int installment = years *


Integer.parseInt(request.getParameter("installment"));
out.println("Total Installments: " + installment + "<br>");

out.println("Installments per year: " + ins + "<br>");

double res = (amount * rate * Math.pow(1+rate,


installment))/(Math.pow(1+rate, installment)-1);

out.println("Installment Ammount: " + res + "<br>");

out.println("Total Ammount to be paid: " + res * installment);

%>
</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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy