[Link] and implement AWT programes for the following.
A)ButtonDemo
[Link].*;
[Link].*;
[Link].*;
/*
<applet code="ButtonDemo" width=240 height=200></applet>
*/
public class ButtonDemo extends Applet implements ActionListener
String msg=" ";
Button yes,no,maybe;
public void init()
yes=new Button("Yes");
no=new Button("No");
maybe=new Button("Undecided");
add(yes);
add(no);
add(maybe);
[Link](this);
[Link](this);
[Link](this);
public void actionPerformed(ActionEventae)
{
String str=[Link]();
if([Link]("yes"))
msg="you pressed yes";
else if([Link]("no"))
msg="you pressed no";
else
msg="you pressed undecided";
repaint();
public void paint(Graphics g)
[Link](msg,6,100);
Output
B)CHECK BOX Demo:
[Link].*;
[Link].*;
[Link].*;
/*
<applet code="CBGroupDemo" width=240 height=200></applet>
*/
public class CBGroup extends Applet implements ItemListener { String msg = "";
Checkbox windows, android, solaris, mac;
CheckboxGroupcbg;
public void init() {
cbg = newCheckboxGroup();
windows = new Checkbox("Windows", cbg, true);
android = new Checkbox("Android", cbg, false);
solaris = new Checkbox("Solaris", cbg, false);
mac = new Checkbox("Mac OS", cbg, false);
add(windows);
add(android);
add(solaris);
add(mac);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
public void itemStateChanged(ItemEventie) { repaint();
public void paint(Graphics g) {
msg = "Current selection: ";
msg += [Link]().getLabel();
[Link](msg, 6, 100);
Output:
c) choice demo:
[Link].*;
[Link].*;
[Link].*;
/*
<applet code="ChoiceDemo" width=240 height=200></applet>
*/
public class ChoiceDemo extends Applet implements ItemListener
Choice os,browser;
String msg=" ";
public void init()
os=new Choice();
browser=new Choice();
[Link]("windows");
[Link]("andriod");
[Link]("solaris");
[Link]("mac os");
[Link]("Internet explorer");
[Link]("fire fox");
[Link]("chrome");
add(os);
add(browser);
[Link](this);
[Link](this);
public void itemStateChanged(ItemEventie)
repaint();
public void paint(Graphics g)
msg="current os:";
msg+=[Link]();
[Link](msg,6,120);
msg="current browser:";
msg+=[Link]();
[Link](msg,6,140);
Output:
d) TEXT AREA
[Link].*;
[Link].*;
/*
<applet code="TextAreaDemo " width=300 height=250></applet>
*/
public class TextAreaDemo extends Applet
public void init()
String val ="Java 8 is the latest version of the most\n" +
"widely-used computer language for Internet programming.\n" + "Building on a rich heritage, Java
has advanced both\n" + "the art and science of computer language design.\n\n" +
"One of the reasons for Java's ongoing success is its\n" + "constant, steady rate of evolution. Java has
never stood\n" + "still. Instead, Java has consistently adapted to the\n" + "rapidly changing landscape
of the networked world.\n" + "Moreover, Java has often led the way, charting the\n" + "course for
others to follow.";
TextArea text = new TextArea(val, 10, 30); add(text);
Output
[Link] and implement AWT programs for the following.
a)MYMENU
b)FRAME
c)LIST
d)GRID LAYOUT
a)MyMenu
import [Link].*;
import [Link].*;
public class Menus extends Frame implements
ActionListener
{
Menu File,Edit;
public Menus(){
MenuBar mb=new MenuBar();
setMenuBar(mb);
File=new Menu("File");
Edit=new Menu("Edit");
[Link](File);
[Link](Edit);
[Link](this);
[Link](this);
[Link](new MenuItem("New"));
[Link](new MenuItem("Open"));
[Link](new MenuItem("Save"));
[Link](new MenuItem("Save As"));
[Link]();
[Link](new MenuItem("Pagesetup"));
[Link](new MenuItem("Print"));
[Link](new MenuItem("Undo"));
[Link](new MenuItem("Cut"));
[Link](new MenuItem("Copy"));
[Link](new MenuItem("Paste"));
[Link]();
[Link](new MenuItem("Find"));
[Link](new MenuItem("FindNext"));
[Link](new MenuItem("Replace"));
[Link](new MenuItem("Goto"));
[Link]();
[Link](new MenuItem("SelectAll"));
[Link](new MenuItem("Time/Date"));
setTitle("Example Menu");
setSize(500,500);
setVisible(true);
public void actionPerformed(ActionEvent e)
String str=[Link]();
[Link]("your selected"+str);
public static void main(String args[])
new Menus();
Output:
b)Frame
import [Link].*;
class First extends Frame{
First(){
Button b=new Button("click me");
[Link](30,100,80,30);// setting button position
add(b);//adding button into frame
setSize(300,300);//frame size 300 width and 300 height
setLayout(null);//no layout manager
setVisible(true);//now frame will be visible, by default not visible
public static void main(String args[]){
First f=new First();
}}
Output:
c)LIST:
[Link].*;
[Link].*;
[Link].*;
/*
<applet code="List" width=240 height=200></applet>
*/
public class ListDemo extends Applet implements ActionListener
List os, browser;
String msg = "";
public void init()
{
os = new List(4, true);
browser = new List(4, false);
[Link]("Windows");
[Link]("Android");
[Link]("Solaris");
[Link]("Mac OS");
[Link]("Internet Explorer");
[Link]("Firefox");
[Link]("Chrome");
[Link](1);
add(os);
add(browser);
[Link](this);
[Link](this);
public void actionPerformed(ActionEventae) { repaint();
public void paint(Graphics g)
intidx[];
msg = "Current OS: ";
idx = [Link]();
for(inti=0; i<[Link]; i++)
msg += [Link](idx[i]) + " ";
[Link](msg, 6, 120);
msg = "Current Browser: ";
msg += [Link]();
[Link](msg, 6, 140);
output:
d) GRID LAYOUT:
[Link].*;
[Link].*;
/*<applet code="GridLayoutDemo" width=300 height=200></applet>*/
public class GridLayoutDemo extends Applet
static final int n = 4;
public void init() {
setLayout(new GridLayout(n, n));
setFont(new Font("SansSerif", [Link], 24));
for(inti = 0; i< n; i++) { for(int j = 0; j < n; j++)
int k = i * n + j; if(k > 0)
add(new Button("" + k));
Out put:
[Link] and implement swings programes for the following .
a)sliders
b)image viewer
c)combo box
a)sliders
import [Link].*;
public class SliderExample1 extends JFrame{
public SliderExample1() {
JSlider slider = new JSlider([Link], 0, 50, 25);
JPanel panel=new JPanel();
[Link](slider);
add(panel);
public static void main(String s[]) {
SliderExample1 frame=new SliderExample1();
[Link]();
[Link](true);
Output:
b)ImageViewer
import [Link].*;
import [Link];
public class Mycanvas extends Canvas{
public void paint(Graphics g) {
Toolkit t=[Link]();
Image i=[Link]("[Link]");
[Link](i, 120,100,this);
public static void main(String[] args) {
Mycanvas m=new Mycanvas();
JFrame f=new JFrame();
[Link](m);
[Link](400,400);
[Link](true);
}
c)ComboBox
import [Link].*;
public class ComboBoxExample {
JFrame f;
ComboBoxExample(){
f=new JFrame("ComboBox Example");
String country[]={"India","Aus","U.S.A","England","Newzealand"};
JComboBox cb=new JComboBox(country);
[Link](50, 50,90,20);
[Link](cb);
[Link](null);
[Link](400,500);
[Link](true);
public static void main(String[] args) {
new ComboBoxExample();
}
Output:
4.. Write and implement swings programes for the following .
a) Tables.
b) Tabbed panes:
c)SCROLL PANES
a)Tables
import [Link].*;
public class TableExample {
JFrame f;
TableExample(){
f=new JFrame();
String data[][]={ {"101","Amit","670000"},
{"102","Jai","780000"},
{"101","Sachin","700000"}};
String column[]={"ID","NAME","SALARY"};
JTable jt=new JTable(data,column);
[Link](30,40,200,300);
JScrollPane sp=new JScrollPane(jt);
[Link](sp);
[Link](300,400);
[Link](true);
public static void main(String[] args) {
new TableExample();
}
Output:
b)TabbedPanes
classCitiesPanel extends JPanel {
publicCitiesPanel() {
JButton b1 = new JButton("New York"); add(b1);
JButton b2 = new JButton("London"); add(b2);
JButton b3 = new JButton("Hong Kong"); add(b3);
JButton b4 = new JButton("Tokyo"); add(b4);
classColorsPanel extends JPanel {
publicColorsPanel() {
JCheckBox cb1 = new JCheckBox("Red"); add(cb1);
JCheckBox cb2 = new JCheckBox("Green"); add(cb2);
JCheckBox cb3 = new JCheckBox("Blue"); add(cb3);
classFlavorsPanel extends JPanel {
publicFlavorsPanel() {
JComboBox<String>jcb = new JComboBox<String>();
[Link]("Vanilla"); [Link]("Chocolate");
[Link]("Strawberry");
add(jcb);
}
output:
c)scroll panes:
[Link].*;
[Link].*;
/* <applet code="JScrollPaneDemo" width=300 height=250></applet>
*/
public class JScrollPaneDemo extends JApplet {
public void init() { try {
[Link]( new Runnable() {
public void run() {
makeGUI();
}
}
);
} catch (Exception exc) {
[Link]("Can't create because of " + exc);
}
}
private void makeGUI() {
// Add 400 buttons to a panel.
JPaneljp = new JPanel(); [Link](new GridLayout(20, 20));
int b = 0;
for(inti = 0; i< 20; i++) { for(int j = 0; j < 20; j++) {
[Link](new JButton("Button " + b)); ++b;
}
}
//Create the scroll pane.
JScrollPanejsp = new JScrollPane(jp);
add(jsp, [Link]);
}
}
Output:
5) write and implement TC/IP client side and server side programes?
TCP SERVER
import [Link].*;
import [Link].*;
classTCPServer{
public static void main(String argv[]) throws Exception {
String clientSentence;
String capitalizedSentence;
ServerSocketwelcomeSocket = newServerSocket(6789);
while (true) {
Socket connectionSocket = [Link]();
BufferedReaderinFromClient =
newBufferedReader(newInputStreamReader([Link]()));
DataOutputStreamoutToClient =
newDataOutputStream([Link]());
clientSentence = [Link]();
[Link]("Received: " + clientSentence);
capitalizedSentence = [Link]() + 'n';
[Link](capitalizedSentence);
}
}
}
TCPClient
import [Link].*;
import [Link].*;
classTCPClient{
public static void main(String argv[]) throws Exception {
String sentence;
String modifiedSentence;
BufferedReaderinFromUser = newBufferedReader(newInputStreamReader([Link]));
Socket clientSocket = newSocket("localhost", 6789);
DataOutputStreamoutToServer = newDataOutputStream([Link]());
BufferedReaderinFromServer =
newBufferedReader(newInputStreamReader([Link]()));
sentence = [Link]();
[Link](sentence + 'n');
modifiedSentence = [Link]();
[Link]("FROM SERVER: " + modifiedSentence);
[Link]();
}
6) ) write and implement UDP client side and server side programes?
UDPServer:
import [Link].*;
import [Link].*;
classUDPServer
{
public static void main(String args[]) throws Exception
{
DatagramSocketserverSocket = new DatagramSocket(9876);
byte[] receiveData = new byte[1024];
byte[] sendData = new byte[1024];
while(true)
{
DatagramPacketreceivePacket = new DatagramPacket(receiveData,
[Link]);
[Link](receivePacket);
String sentence = new String([Link]());
[Link]("RECEIVED: " + sentence);
InetAddressIPAddress = [Link]();
int port = [Link]();
String capitalizedSentence = [Link]();
sendData = [Link]();
DatagramPacketsendPacket =
newDatagramPacket(sendData, [Link], IPAddress, port);
[Link](sendPacket);
}
}
}
[Link]:
import [Link].*;
import [Link].*;
classUDPClient
{
public static void main(String args[]) throws Exception
{
BufferedReaderinFromUser =
newBufferedReader(new InputStreamReader([Link]));
DatagramSocketclientSocket = new DatagramSocket();
InetAddressIPAddress = [Link]("localhost");
byte[] sendData = new byte[1024];
byte[] receiveData = new byte[1024];
String sentence = [Link]();
sendData = [Link]();
DatagramPacketsendPacket = new DatagramPacket(sendData, [Link],
IPAddress, 9876);
[Link](sendPacket);
DatagramPacketreceivePacket = new DatagramPacket(receiveData,
[Link]);
[Link](receivePacket);
String modifiedSentence = new String([Link]());
[Link]("FROM SERVER:" + modifiedSentence);
[Link]();
}
}
7)write and implement JDBC program?
public class FirstExample
{ import [Link].*;
static final String JDBC_DRIVER="[Link]";
static final String DB_URL="jdbc:mysql://localhost//EMP";
static final String USER="username";
static final String PASS="password";
public static void main(String args [])
Connection conn=null;
Statement stmt=null;
try
[Link]("[Link]");
[Link]("connecting to database........");
conn=[Link](DB_URL,USER,PASS);
[Link]("Creating Statement........");
stmt=[Link]();
String sql;
sql="SELECT id,first,last,age FROM Employes";
ResultSet rs=[Link](sql);
while([Link]())
int id=[Link]("id");
int age=[Link]("age");
String first=[Link]("first");
String last=[Link]("last");
[Link]("Id:"+id);
[Link]("Age:"+age);
[Link]("First:"+first);
[Link]("Last:"+last);
[Link]();
[Link]();
[Link]();
catch(SQLException se)
[Link]();
catch(Exception e)
[Link]();
finally
try
if(stmt!=null)
[Link]();
catch(SQLException se2)
{
}
try
if(conn!=null)
[Link]();
catch(SQLException se)
[Link]();
[Link]("Goodbye!");
}
8) write and implement RMI program?
INTERFACE:
import [Link].*;
interface Bank extends Remote
double getAmount(double p,double t)throws RemoteException;
BANK SERVER:
import [Link].*;
import [Link];
public class BankImpl throws UniCastRemote Object implements Bank
public BankImpl throws RemoteException
double getAmount(double p, double t)throws RemoteException
return p*[Link](1.41t);
RMI REGISTRY:
import [Link].*;
import [Link].*;
public class BankServer
public static void main(String args[])
{
BankImpl centralBank=new BankImpl();
[Link]("uti",centralBank);
BANK CLIENT:
import [Link].*;
import [Link].*;
public static void main (String args[])throws REmoteException
String url="rmi://local Host//uti";
Bank b=(Bank)[Link](url);
[Link]([Link](4000,3));
}
9) write and implement for making simple servlets?
Simple servlets:
import [Link].*;
import [Link].*;
import [Link].*;
public class FirstServlet extends HttpServlet
public void doPost(HttpServletRequest request,HttpServletResponse response)
try
[Link] type("text/html");
PrintWriter out=[Link]();
String n=[Link]("userName");
[Link]("welcome"+n);
Cookie ck=new Cookie("uname",n);
[Link](ck);
[Link]("<from action=servlet>");
[Link]("<input type='submit' value='go'>");
[Link]("</form>");
[Link]();
catch(Exception e)
[Link](e);
}
}}
10) write and implement HTML programs for the following
a)Lists b)Forms c)Frames d)Tables e)Images
a)Lists
<html>
<head>
<title>LIST</title>
</head>
<body>
<h1 align="center"><u>LIST</u></h1>
<h2>An Unordered HTML List</h2>
<ul type="square">
<li>Lion</li>
<li>Tiger</li>
<li>Elephant</li>
</ul>
<h2>An Ordered HTML List</h2>
<ol type="1">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
<h2> DEFINATION LIST</h2>
<dl>
<dt>computer</dt>
<dd>computer is an electronic device,it takes data from user and process the data</dd>
</dl>
</body>
</html>
OUTPUT:
b)Forms
<html>
<head>
<title>BIO DATA</title>
</head>
<body>
<form method="get">
<h2 align=center>BIODATA</h2>
<font color=red >NAME<input type=text name="a1"size=15><br><br>
DOB<input type=text name="a2"size=1>
<input type=text name="a3"size=1>
<input type=text name="a4"size=1>
<input type=text name="a5"size=1>
<input type=text name="a6"size=1>
<input type=text name="a7"size=1>
<input type=text name="a8"size=1>
<input type=text name="a9"size=1><br><br>
GENDER  <br>
Male<input type=radio name="a10">
Female<input type=radio name="a10"><br><br>
Address<textarea name="a11" rows=10 cols=10></textarea><br><br>
Phone no<input type=text name="a12" size=20><br><br>
Email id<input type=text name="a13" size=20><br><br>
Qualification<input type=text name="a14" size=20><br><br>
Comapay Address<textarea name="a15" rows=10
cols=10></textarea><br><br>
Project Details<textarea name="a15" rows=10 cols=10></textarea><br><br>
<table border=5 bordercolor=pink>
<tr>
<th>eno</th>
<th>ename</th>
<th>Location</th>
<th>from</th>
<th>to</th>
</tr>
<tr>
<td>  </td>
<td>  </td>
<td>  </td>
<td>  </td>
<td>  </td>
</tr>
<tr>
<td>  </td>
<td>  </td>
<td>  </td>
<td>  </td>
<td>  </td>
</tr>
</table><br>
<input type=Submit value=submit size=10> 
<input type=Reset value=reset size=10> 
</form>
</body>
</html>
Output:
c)Frames
<html>
<head>
<title>FRAMES</title>
</head>
<frameset cols="50%,50%">
<frame src="[Link]" name="left frame">
<frame src="[Link]" name="right frame">
</frame set>
</html>
//save with [Link]
<html>
<head>
<title>CONTENTS</title>
</head>
<body link="red alink="green" vlink="blue">
<h1>CONTENTS</h1>
<ul>
<a href="[Link]" target="right frame">Birds</a><br>
<a href="[Link]" target="right frame">Animals</a><br>
<a href="[Link]" target="right frame">Flowers</a><br>
<a href="[Link]" target="right frame">Colors</a><br>
</ul>
</body>
</html>
//save with [Link]
<html>
<head>
<title>INFORMATION</title>
</head>
<body>
<br><br><br>
<p> Select any one from left frame to get Information </p>
</body>
</html>
//save with [Link]
<html>
<head>
<title>BIRDS</title>
</head>
<body>
<h1>BIRDS</h1>
<ul>
<li>Peacock
<li>Parrot
<li>Pigeon
<li>Sparrow
<li>Hallyon
</ul>
</body>
</html>
//save with [Link]
<html>
<head>
<title>ANIMALS</title>
</head>
<body>
<h1>ANIMALS</h1>
<ul>
<li>Lion
<li>Tiger
<li>Cow
<li>Cat
<li>Elephant
</ul>
</body>
</html>
//save with [Link]
<html>
<head>
<title>FLOWERS</title>
</head>
<body>
<h1>FLOWERS</h1>
<ul>
<li>Rose
<li>Lilly
<li>Jasmin
<li>Lotus
<li>Marrigold
</ul>
</body>
</html>
//save with [Link]
<html>
<head>
<title>COLORS</title>
</head>
<body>
<h1>COLORS</h1>
<ul>
<li>Pink
<li>Oline
<li>Cyan
<li>Blue
<li>Red
</ul>
</body>
</html>
Output:
d)Tables:
<html>
<head>
<title>time table</title>
</head>
<body bgcolor="blue">
<H1><FONT COLOR=""><CENTER>COLLEGE TIME TABLE</FONT></H1>
<table border="2" cellspacing="3" align="center">
<tr>
<td align="center">DAY
<td>9:00-10:00
<td>10:00-11:00
<td>11:00-12:00
<td>12:00-1:00
<td>1:00-2:00
<td>2:00-3:00
<td>3:00-4:00
<td>4:00-5:00
</tr>
<tr>
<td align="center">MONDAY
<td align="center"><font color="green">CN<br>
<td align="center"><font color="green">CN<br>
<td align="center"><font color="red">UNIX<br><td align="center"><font
color="red">UNIX<br>
<td rowspan="6"align="center">L<br>U<br>N<br>C<br>H
<td align="center"><font color="brown">DAA<br>
<td align="center"><font color="brown">DAA<br>
<td align="center">library
</tr>
<tr>
<td align="center">TUESDAY
<td align="center"><font color="red">DBMS<br>
<td align="center"><font color="red">DBMS<br>
<td colspan="2" align="center"><font color="blue">AJP LAB<br>
<td align="center"><font color="orange">DBMS <BR>
<td align="center"><font color="orange">DBMS <br>
<td align="center">library
</tr>
<tr>
<td align="center">WEDNESDAY
<td align="center">---<br>
<td align="center"><font color="orange">CN<BR>
<td align="center"><font color="orange">CN<br>
<td align="center">---<br>
<td colspan="2" align="center"><font color="green">DBMS lab
<td align="center"><font color="brown">Seminors
</tr>
<tr>
<td align="center">THURSDAY
<td align="center"><font color="brown">AJP<br>
<td align="center"><font color="brown">AJP<br>
<td align="center"><font color="orange">DAA<br>
<td align="center"><font color="orange">DAA<br>
<td align="center"><font color="red">UNIX<br>
<td align="center"><font color="red">UNIX<br>
<td align="center">seminors
</tr>
<tr>
<td align="center">FRIDAY
<td align="center">---<BR>
<td align="center"><font color="maroon">UNIX<br>
<td align="center"><font color="maroon">UNIX<br>
<td align="center">---
<td align="center"><font color="brown">CN<br>
<td align="center"><font color="brown">CN<br>
<td align="center">library
</tr>
<tr>
<td align="center">SATURDAY
<td align="center">----<br>
<td align="center"><font color="blue">swacth barath<br>
<td align="center"><font color="blue">AJP<br>
<td align="center"><font color="blue">AJP<br>
<td align="center"><font color="brown">UNIX<br>
<td align="center"><font color="brown">UNIX<br>
<td align="center"><font color="brown">seminors<br>
</tr>
</body>
</html>
Output
e) Images
<html>
<head>
<title>TABLE WITH IMAGES</title>
</head>
<body>
<table align=center border=5>
<caption><h1> TABLE WITH IMAGES</h1</caption>
<tr>
<td><img src=[Link] width=150 height=150></td>
<td><img src=[Link] width=150 height=150></td>
<td><img src=[Link] width=150 height=150></td>
<td><img src=[Link] width=150 height=150></td>
</tr>
<tr>
<td><img src=[Link] width=150 height=150></td>
<td colspan=2 align=center>TABLE WITH IAMGES</td>
<td><img src=[Link] width=150 height=150></td>
</tr>
<tr>
<td><img src=[Link] width=150 height=150></td>
<td><img src=[Link] width=150 height=150></td>
<td><img src=[Link] width=150 height=150></td>
<td><img src= [Link] width=150 height=150></td>
</tr>
</table>
</body>
</html>
Output:
11) write and implement HTML programs for css for the following use of different styles?
a)Inline b)Embedded c)Fonts and colors
a)Inline
<!DOCTYPE html>
<html>
<head>
<title>Playing with Inline styles</title>
</head>
<body>
<p style="color:blue;font-size:46px;">
I'm a big ,blue,<strong>strong</strong>paragraph
</p>
</body>
</html>
Output:
b)Embedded
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
p{
font-family:georgia,serif;
font-size:x-large;
color:#ff9900;
a:hover{
color:LimeGreen;
text-decoration:none;
</style>
</head>
<body>
<p>This paragraph tag has been preset
using embedded style [Link] for the
horizental rule below and the hyperlinek
under that.</p>
<p>Also see<a
href="/css/external_style_sheets.cfm"
target="_blank">external style sheets</a>
</p>
</body>
</html>
Output:
c)Fonts and Colors
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-size: 100%;
h1 { color: red; }
h2 { color: #9000A1; }
p { color:rgb(0, 220, 98); }
</style>
</head>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<p>This is a paragraph.</p>
</body>
</html>
Output:
12) write and implement HTML program for css for the following use of different styles
A)Linking ExternalStyle b)Creating a background image background i) repeat
ii)norepeat c) creating background image with background i) repeat ii)norepeat
A)Linking ExternalStyle
<html>
<head><html>
<head>
<title>stylesheet</title>
<style type="text/css">
@import URL("[Link]");
@import URL("[Link]");
</style>
</head>
<body>
<h1>AMMULU</h1>
<p>HII FRIENDS</p>
<img src="[Link]">
</body>
</html>
Output:
b) Creating a background image background
i) repeat:-
<html>
<head>
<style>
body
background-image:url("[Link]");
background-repeat:repeat;
</style>
</head>
<body>
<h1>Hello world!</h1>
<p>the images are repeated</p>
<p>the background images is only showing once,but it is disturbing the reader!</p>
</body>
</html>
Output:-
ii) no-repeat:-
<html>
<head>
<style>
body
background-image:url("[Link]");
background-repeat:no-repeat;
</style>
</head>
<body>
<h1>Hello world!</h1>
<p>the images are non_repeated</p>
<p>the background images is only showing once,but it is disturbing the reader!</p>
</body>
</html>
Output:-
c) creating background image with background
a) repeate:-
<html>
<head>
<body>
<style>
body
background-image:url("[Link]");
background-repeat:repeat
</style>
</head>
<body bgcolor="orange">
<h1><font color="pink">hello world!
</font>
</h1>
<p><font color="pink">the images are
repeated</font></p>
</body>
</html>
Output:
b) no-repeat:-
<html>
<head>
<body>
<style>
body
background-image:url("[Link]");
background-repeat:no-repeat
</style>
</head>
<body bgcolor="orange">
<h1><font color="pink">hello world!
</font>
</h1>
<p><font color="pink">the images are
repeated</font></p>
</body>
</html>
Output:
13) write and implement HTML program for generating calculator using java script?
<html>
<head>
<title>Calculator</title>
<style>
#text1,#text2{
button{
width:100%;
height:100%;
</style>
<script>
function event1(x){
[Link]("text1").value+=x;
function event2(){
var x = [Link]("text1").value;
[Link]("text1").value = eval(x);
</script>
</head>
<body>
<center>
<table border="1">
<tr>
<thcolspan=4><h1>Calculator</h1></th>
</tr>
<tr>
<td colspan=4><input type="text" id="text1" placeholder="0" style="text-align:right;"/></td>
</tr>
<tr>
<td></td>
<td><button type="button" value="/" onClick="event1([Link])">/</button></td>
<td><button type="button" value="*" onClick="event1([Link])">*</button></td>
<td><button type="button" value="-" onClick="event1([Link])">-</button></td>
</tr>
<tr>
<td><button type="button" value="7" onClick="event1([Link])">7</button></td>
<td><button type="button" value="8" onClick="event1([Link])">8</button></td>
<td><button type="button" value="9" onClick="event1([Link])">9</button></td>
<td rowspan=2><button type="button" value="+" style="height:50px;"
onClick="event1([Link])">+</td>
</tr>
<tr>
<td><button type="button" value="4" onClick="event1([Link])">4</button></td>
<td><button type="button" value="5" onClick="event1([Link])">5</button></td>
<td><button type="button" value="6" onClick="event1([Link])">6</button></td>
</tr>
<tr>
<td><button type="button" value="1" onClick="event1([Link])">1</button></td>
<td><button type="button" value="2" onClick="event1([Link])">2</button></td>
<td><button type="button" value="3" onClick="event1([Link])">3</button></td>
<td rowspan=2><button type="button" style="height:48px;" onClick="event2()"
>=</button></td>
</tr>
<tr>
<td colspan=2><button type="button" style="width:100%">0</button></td>
<td><button type="button">.</button></td>
</tr>
</table>
</center>
</body>
</html>
Output:
14) write and implement program using javascript objects for the following?
a) string b)date c)Boolean d)math
a) string
<html>
<body>
<h2>JavaScriptStrings</h2>
<p>Strings can be written with double or single quotes</p>
<p id="demo">
</p>
<script>
[Link]("demo").innerHTML= "John Doe";
</script>
</body>
</html>
Output:
JavaScriptStrings
Strings can be written with double or single quotes
John Doe
b)date
<html>
<body>
<h2>JavaScript new Date</h2>
<p id="demo">
</p>
<script>
var d=new Date();
[Link]("demo").innerHTML=d;
</script>
</body>
</html>
Output:
JavaScript new Date
Thu Nov 08 2018 09:52:18 GMT+0530 (India Standard Time)
c)Boolean
<html>
<body>
<p>Display the value of Boolean(10 > 9):</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
document . getElementById("demo").innerHTML = Boolean(10 > 9);
</script>
</body>
</html>
Output:
Display the value of Boolean(10 > 9):
true
d) math
<html>
<body>
<h2>JavaScript [Link]()</h2>
<p>[Link]() returns a random number between 0 (included) and 1 (excluded):</p>
<p id="demo"></p>
<script>
[Link]("demo").innerHTML = [Link]();
</script>
</body>
</html>
Output:
JavaScript [Link]()
[Link]() returns a random number between 0 (included) and 1 (excluded):
0.8385727260271957
15)write and implement programs using java script objects for the following?
a)Array b)Navigator c)window d)Document
(A)JS ARRAY
<html>
<body>
<h2>JavaScript Arrays</h2>
<p>[Link]() calls a function for each array element.</p>
<p>[Link]() is not supported in Internet Explorer 8 or earlier.</p>
<p id="demo"></p>
<script>
var fruits, text;
fruits = ["Banana", "Orange", "Apple", "Mango"];
text = "<ul>";
[Link](myFunction);
text += "</ul>";
[Link]("demo").innerHTML = text;
functionmyFunction(value) {
text += "<li>" + value + "</li>";
</script>
</body>
</html>
JS NAVIGATOR
<html>
<body>
<h2>JavaScript Navigator</h2>
<p>The appCodeName property returns the code name of the browser.</p>
<p>Do not rely on it! "Mozilla" is the application code name for both Chrome, Firefox, IE, Safari, and
Opera.</p>
<p id="demo"></p>
<script>
[Link]("demo").innerHTML =
"[Link] is " + [Link];
</script>
</body>
</html>
Out put:
JS WINDOW
<html>
<body>
<p id="demo"></p>
<script>
var w = [Link]
|| [Link]
|| [Link];
var h = [Link]
|| [Link]
|| [Link];
var x = [Link]("demo");
[Link] = "Browser inner window width: " + w + ", height: " + h + ".";
</script>
</body>
</html>
Out put:
JS DOCUMENT
<html>
<body>
<p>Click the button to open a new window called "MsgWindow" with some text.</p>
<button onclick="myFunction()">Try it</button>
<script>
functionmyFunction() {
varmyWindow = [Link]("", "MsgWindow", "width=200,height=100");
[Link]("<p>This is 'MsgWindow'. I am 200px wide and 100px tall!</p>");
</script>
</body>
</html>
Out put: