JAVA PROGRAMMING
PRACTICE PROGRAMMING QUESTIONS
SET A
Develop a simple web application that includes an html form to read the EB service
number and the number of units consumed from the user and submits the request to the
servlet. The servlet should calculate the bill amount using the criteria given below and
send back the result.
UNITS FROM TO UNITS UNIT COST
1 100 Rs. 0
101 400 Rs.4.50
401 500 Rs. 6
501 600 Rs. 8
601 800 Rs.9
801 1000 Rs. 10
>1000 Rs. 11
Solution:
HTML Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Electricity Bill Calculator</title>
</head>
<body>
<h2>Electricity Bill Calculator</h2>
<form action="/YourServletName" method="post">
<label for="serviceNumber">EB Service Number:</label>
<input type="text" id="serviceNumber" name="serviceNumber" required><br>
<label for="unitsConsumed">Number of Units Consumed:</label>
<input type="text" id="unitsConsumed" name="unitsConsumed" required><br>
<button type="submit">Calculate Bill</button>
</form>
</body>
</html>
PRACTICE PROGRAMMING QUESTIONS
SET A
Develop a simple web application that includes an html form to read the EB service
number and the number of units consumed from the user and submits the request to the
servlet. The servlet should calculate the bill amount using the criteria given below and
send back the result.
UNITS FROM TO UNITS UNIT COST
1 100 Rs. 0
101 400 Rs.4.50
401 500 Rs. 6
501 600 Rs. 8
601 800 Rs.9
801 1000 Rs. 10
>1000 Rs. 11
Solution:
HTML Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Electricity Bill Calculator</title>
</head>
<body>
<h2>Electricity Bill Calculator</h2>
<form action="/YourServletName" method="post">
<label for="serviceNumber">EB Service Number:</label>
<input type="text" id="serviceNumber" name="serviceNumber" required><br>
<label for="unitsConsumed">Number of Units Consumed:</label>
<input type="text" id="unitsConsumed" name="unitsConsumed" required><br>
<button type="submit">Calculate Bill</button>
</form>
</body>
</html>