import java.awt.*;
import java.applet.Applet;
import java.lang.*;
public class Param extends Applet
{
String name,hno,city,pin;
public void init()
{
name=getParameter("Name");
hno=getParameter("HouseNumber");
city=getParameter("City");
pin=getParameter("PinCode");
}
public void paint(Graphics g)
{
g.setColor(Color.BLUE);
g.setFont(new Font("Georgia", Font.PLAIN, 20));
g.drawString("Address of a Person:",10, 80);
try
{
Integer.parseInt(name);
g.drawString("Enter proper name!",10,120);
}
catch (NumberFormatException e)
{
g.drawString("Name:"+name,10,120);
}
g.drawString("HouseNo:"+hno,10,160);
try
{
Integer.parseInt(city);
g.drawString("Enter proper city!",10,200);
}
catch (NumberFormatException e)
{
g.drawString("City:"+city,10,200);
}
try
{
Integer.parseInt(pin);
g.drawString("PinCode:"+pin,10,240);
}
catch (NumberFormatException e)
{
g.drawString("Enter proper Pincode!",10,240);
}
}
}
/*
<html>
<body>
<applet code=Param.class width=500 height=500>
<param name="Name" value="ABC">
<param name="HouseNumber" value="123">
<param name="City" value="Shimoga">
<param name="PinCode" value="12345">
</applet>
</body>
</html>
*/
Search This Blog
Wednesday, 1 September 2021
B6. Write an applet to display the address of a person (atleast 4 lines) using parameter passing concept. Appropriate message should be displayed for wrong input.
Labels:
New_Java_Programs
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment