Assignment -1
1. Start your web page with an <html> tag.
i) Add a heading.
ii) Add a title.
iii) Start the <body> section.
iv) Add the following text using <H1> and </H1> tags:
This Web page was designed by (your name)
v) Add the following text using <H2> and </H2> tags: My HTML assignment
vi) Add a horizontal line
vii) Insert an image to your web page.
Note: You should then refer to your image with just the filename, and NOT the entire pathname to the file.
viii) Add another horizontal line.
ix) Enter a paragraph of text.
Write about things you have learned in html.
Make sure the text in this paragraph is a color other than black, but something one can see.
Add a link that takes you to your favorite webpage.
x) Start a new paragraph. Add a three item ordered list. Make it creative (don’t just say item 1, item 2, etc… and keep it clean)!
xi) Close out your body and html tags.
Source code
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head>
<title>bum</title>
<meta charset=”utf-8″>
</head>
<body>
<h1>This website is designed by Bum kailash kumar</h1>
<h2> My HTML Assignments</h2>
<hr>
<img src=”bbitlogo.gif” alt=”image not found” height=”250″ width=”250″>
<img src=”bbitlogo.gif” alt=”image not found” height=”250″ width=”250″ >
<hr>
<p><font color=”#1C8000″> Learned about heading, title, body and adding image,drawing horizontal line</font><p>
<a href=”https://bumkailashkumar.blogspot.in”>bum_blogspot</a>
<p>
<ol>
<li>1.Coffee</li>
<li>2.Milk</li>
<li>3.Tea</li>
</ol>
</p>
</body>
</html>
Output
Assignment -2
2. Start your web page with an <html> tag.
i) Add a heading.
ii) Add a title.
iii) Start the <body> section.
iv) Start a new paragraph.
Use alignment attribute,
Use bold, italic, underline tags,
Use font tag and associated attributes,
Use heading tags,
Use preserve tag,
Use non breaking spaces (escape character).
Source code
<html>
<head>
<title>bumkailashkumar</title>
<meta charset=”utf-8″ />
</head>
<body>
<p>This is a paragraph</p>
<p><u><b><i>using alignment attribute bold,italic and underline.</i></b></u></p>
<font size=”5″ color=”green”>this is a font attribute.</font>
<h1>heading tag of size h1</h1>
<h2>heading size of h2</h2>
<pre>
Name-bumkailashkumar
Branch-CSE
</pre>
<P>HERE IS A NON BREAKING SPACE</P>
</body>
</html>
Output
Assignment -3
3. Start your web page with an <html> tag.
i) Add a heading.
ii) Add a title.
iii) Start the <body> section.
iv) Start a new paragraph.
Create Hyperlinks:
(a) Within the HTML document.
(b) To another URL.
(c) To a file that can be rendered in the browser.
Source code
<!DOCTYPE html>
<html>
<head>
<title>Use of hyperlink</title>
<meta charset=”UTF-8″/>
</head>
<body>
<h3>Types of hyperlink.</h3>
<h2>About HTML</h2>
<a href=”#webpage”>click here to directly go to about webpage section.</a>
<i>Hypertext Markup Language (HTML) is the standard markup language for creating web pages and web applications.
With Cascading Style Sheets (CSS) and JavaScript it forms a triad of cornerstone technologies for the World Wide Web.
Web browsers receive HTML documents from a web server or from local storage and render them into multimedia web pages.
HTML describes the structure of a web page semantically and originally included cues for the appearance of the document.
</i>
HTML elements are the building blocks of HTML pages.
With HTML constructs, images and other objects, such as interactive forms, may be embedded into the rendered page.
It provides a means to create structured documents by denoting structural semantics for text such as headings, paragraphs, lists, links, quotes and other items.
HTML elements are delineated by tags, written using angle brackets.
<h3 id=”webpage”>About webpage</h3>
<p>A web page, or webpage, is a document that is suitable for the World Wide Web and web browsers.
A web browser displays a web page on a monitor or mobile device. The web page is what displays, but the term also refers to a computer file, usually written in HTML or comparable markup language.
Web browsers coordinate the various web resource elements for the written web page, such as style sheets, scripts, and images, to present the web page.
Typical web pages provide hypertext that includes a navigation bar or a sidebar menu to other web pages via hyperlinks, often referred to as links.
On a network, a web browser can retrieve a web page from a remote web server. On a higher level, the web server may restrict access to only a private network such as a corporate intranet or it provides access to the World Wide Web.
On a lower level, the web browser uses the Hypertext Transfer Protocol (HTTP) to make such requests.
A static web page is delivered exactly as stored, as web content in the web server’s file system, while a dynamic web page is generated by a web application that is driven by server-side software or client-side scripting.
Dynamic website pages help the browser (the client) to enhance the web page through user input to the server.</p>
<img src=”web_page.png” alt=”image not found” /></br>
<a href=”https://en.wikipedia.org/wiki/Web_page”>click here to know more about webpage from wikipedia</a></br>
<a href=”Web_page.pdf”>click here to read more about webpage from pdf</a>
</body>
</html>
OUTPUT
Assignment -4
4. Start your web page with an <html> tag.
i) Add a heading.
ii) Add a title.
iii) Start the <body> section.
ii) Add a title.
iii) Start the <body> section.
Create an unordered list,
Create an ordered list,
Use various bullet styles,
Created nested lists,
Use the font tag in conjunction with lists,
Create definition lists
Source code
<!DOCTYPE html>
<html>
<head>
<title>List</title>
<meta charset=”utf-8″/></head>
<body>
<h2>unordered list</h2>
<ul type=”circle”>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
<ul type=”square”>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
<li>item 4</li>
</ul>
<h2>ordered list</h2>
<ol>
<li>ordered list</li>
<li>bullet styles</li>
</ol>
<h2>Nested lists</h2>
<ol>
<li>item 1</li>
<li>item 2
<ol>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ol>
</ol>
<h2>Definition list</h2>
<dl>
<dt>flowers</dt>
<dd>Rose is a flower</dd>
<dt>Fruits</dt>
<dd>Apple is a fruit</dd>
</dl>
</body>
</html>
Output
Assignment-5
5. Start your web page with an <html> tag.
i) Add a heading.
ii) Add a title.
iii) Start the <body> section.
a) Create a simple table
Create borders and adjust border size.
Adjust table cell spacing.
Change border color.
Change table background color.
b) Align a new table on HTML page.
Perform cell text alignment,
Create multi-column tables,
Display information about your academic qualification into this table.
Source code
<!DOCTYPE html>
<html>
<head>
<title>Table</title>
<meta charset=”utf-8″/>
</head>
<body>
<h3>simple table</h3>
<table border=”2″ bordercolor=”red” cellspacing=”5″ bgcolor=”green”>
<tr>
<th>Name</th>
<th>Roll</th>
<th>Branch</th>
</tr>
<tr>
<td>bum</td>
<td>14</td>
<td>CSE</td>
</tr>
</table>
</br>
New table showing text Allignment and Academic details
<table border=”2″>
<tr>
<th>Course</th>
<th>Name of the institution</th>
<th>Board of Examination</th>
<th>year of passing</th>
<th>CGPA/percentage</th>
</tr>
<tr>
<td>B.tech(computer science & Eng.)</td>
<td>Budge budge institute of technology </td>
<td align=”center”>MAKAUT</td>
<td align=”center”>2014-2018</td>
<td align=”center”>1st sem 6.56</br> 2nd sem 6.66</br>3rd sem 6.62</br>4th sem 7.46</br>5th sem 7.27</br>6th sem 8.23</td>
<tr>
<td>Intermediate</td>
<td>Indira gandhi sramic Inter college,Mandu </td>
<td align=”center”>JAC</td>
<td align=”center”>2013</td>
<td align=”center”>53.2%</td>
</tr>
<tr>
<td>Matriculation</td>
<td>Sri Guru Nanak public school,Ramgarh cantt</td>
<td align=”center”>CBSE</td>
<td align=”center”>2010</td>
<td align=”center”>63%</td>
</tr>
</table>
</body>
</html>
OUTPUT
Assignment-6
6. Start your web page with an <html> tag.
i) Add a heading.
ii) Add a title.
iii) Start the <body> section.
Create a frameset:
Use frame tags,
Create vertical (column) frames,
Create horizontal (row) frames,
Create complex framesets,
Use the hyperlink tag to target displaying an HTML page to another frame.
Source code
Demo.html
<html>
<frameset cols=”25%,*,25%”>
<frame src = “menu.html”>
<frame src = “main.html”>
</frameset>
</html>
Main.html
<html>
<body bgcolor = “green”>
<a href = “http://www.google.com” target = “main_page”>Google</a>
<br />
<br />
<a href = “http://www.microsoft.com” target = “main_page”>Microsoft</a>
<br />
<br />
<a href = “http://news.bbc.co.uk” target = “main_page”>BBC News</a>
</body>
</html>
Menu.html
<html>
<body bgcolor = “yellow”>
<a href = “http://www.youtube.com” target = “main_page”>Youtube</a>
<br />
<br />
<a href = “http://www.makautexam.net” target = “main_page”>Makaut</a>
<br />
<br />
<a href = “http://cricbuzz.com” target = “main_page”>Cricbuzz</a>
</body>
</html>
OUTPUT
Assignment-7
7. Start your web page with an <html> tag.
i) Add a heading.
ii) Add a title.
iii) Start the <body> section.
Create a simple HTML form.
Use the input tag to create a: text box; text area box; check box; list box; radio button; password field; popup menu; hidden
field. Use submit and reset buttons. Create an admission form using the above information.
Source code
<DOCTYPE html>
<html>
<head>
<title>form</title>
</head>
<body>
<form method=”post” action=””>
Name : <input /><br>
<input type=”radio” name=”gender” value=”male” checked/>Male<br>
<input type=”radio” name=”gender” value=”Female”/>Female</br>
Physically Handicapped : <select><option>select</option><option>Yes</option><option>No</option></select></br>
Appplicant’s conatct number : <input type=”text” name=”contact”></br>
Aadhar Card No. : <input type=”text” name=”aadhar”></br>
Password : <input type=”password” /><br>
Mothers Name : <input type=”text” name=”mother”></br>
Father’s name : <input type=”text” name=”father” ></br>
<label>Father’s occupation : </label><select><option>Select</option><option>Service</option><option>Bussiness</option><option>Self Employed</option><option>Other</option></select></br>
Address : <textarea name=”address” rows=”4″ cols=”50″ ></textarea></br>
Pin code : <input type=”text” name=”pincode”></br>
I accept terms and conditions <label><input type=”checkbox”></label></br>
<input type=”reset”> <input type=”submit” name=”submit”>
<p>Click reset button to reset the button.</p>
</form>
</body>
</html>
OUTPUT
Assignment-8
8. Create a web page that will include an image. Then create image map to watch different parts of that image closely.
Source code
<html>
<body>
<p>Click on the sun or on one of the planets to watch it closer:</p>
<img src=”planets.gif” width=”145″ height=”126″ alt=”Planets” usemap=”#planetmap”>
<map name=”planetmap”>
<area shape=”rect” coords=”0,0,82,126″ alt=”Sun” href=”sun.htm”>
<area shape=”circle” coords=”90,58,3″ alt=”Mercury” href=”mercur.htm”>
<area shape=”circle” coords=”124,58,8″ alt=”Venus” href=”venus.htm”>
</map>
</body>
</html>
Output
Assignment-9
9. Using frames as an interface, create a series of web pages where the theme is to provide resources (internet, intranet,static HTML pages) pertaining to the subject of HTML. Ideally, your goal is to create a resource that you can use long after
this module when needing information on HTML. As a minimum requirement to this assignment your webpage should:
• Consist of at least 3 frames.
• Contain at least 5 URLs to internet and/or intranet sites that you can reference as part of your job.
• Contain at least 5 references to documents that you have created that you use on a regular basis.
• Contain at least 5 references to documents others have created that you use on a regular basis.
• Be organized in a fashion that is logical and intuitive to you.
• Is done with enough quality that you would not be opposed to it being a link at another site.
Source code
<!DOCTYPE html>
<html>
<head>
<title>Details about HTML</title>
</head>
<frameset rows=”20%,60%,20%”>
<frame src=”frame1.html”>
<frameset cols=”20%,80%”>
<frame src=”frame2.html”>
<frame src=”frame3.html”/>
<frame />
</frameset>
</framset>
</html>
frame1.html
<DOCTYPE html>
<html>
<head>
<title>about html</title>
</head>
<body>
Hypertext Markup Language (HTML) is the standard markup language for creating web pages and web applications. With Cascading Style Sheets (CSS) and JavaScript it forms a triad of cornerstone technologies for the World Wide Web. Web browsers receive HTML documents from a web server or from local storage and render them into multimedia web pages. HTML describes the structure of a web page semantically and originally included cues for the appearance of the document. HTML elements are the building blocks of HTML pages. With HTML constructs, images and other objects, such as interactive forms, may be embedded into the rendered page. It provides a means to create structured documents by denoting structural semantics for text such as headings, paragraphs, lists, links, quotes and other items. HTML elements are delineated by tags, written using angle brackets.
</body>
</html>
frame2.html
<!DOCTYPE html>
<html>
<head>
<title>About website</title>
</head>
<body>
A web page, or webpage, is a document that is suitable for the World Wide Web and web browsers. A web browser displays a web page on a monitor or mobile device. The web page is what displays, but the term also refers to a computer file, usually written in HTML or comparable markup language. Web browsers coordinate the various web resource elements for the written web page, such as style sheets, scripts, and images, to present the web page. Typical web pages provide hypertext that includes a navigation bar or a sidebar menu to other web pages via hyperlinks, often referred to as links. On a network, a web browser can retrieve a web page from a remote web server. On a higher level, the web server may restrict access to only a private network such as a corporate intranet or it provides access to the World Wide Web. On a lower level, the web browser uses the Hypertext Transfer Protocol (HTTP) to make such requests. A static web page is delivered exactly as stored, as web content in the web server’s file system, while a dynamic web page is generated by a web application that is driven by server-side software or client-side scripting. Dynamic website pages help the browser (the client) to enhance the web page through user input to the server.
</body>
</html>
frame3.html
<DOCTYPE html>
<html>
<head>
<title>Links for references</title>
</head>
<body>
<a href=”https://www.w3schools.com”>click here to Learn HTML from w3c school</a></br>
<a href=”https://www.tutorialspoint.com/html/”>click here to know more from tutorials point</a></br>
<a href=”http://html5css3sourcecode.blogspot.in/”>learn about CSS</a></br>
<a href=”https://developer.mozilla.org/en-US/docs/Learn/HTML”>learn html from mozilla foundation</a></br>
<a href=”https://www.codecademy.com/courses”>Learn by developing yourself</a></br>
</body>
</html>
Output
Assignment-10
10. Create a web page as you wish and the html elements of the page will be styled by CSS.
Source code
<!DOCTYPE html>
<html>
<head>
<title>table in html</title>
<link rel=”stylesheet” href=”style.css”>
</head>
<body>
<table border=”5″ cellpadding=”5″ cellspacing=”0″>
<tr>
<th id=”idcolor” rowspan=”2″>
ID
</th>
<th id=”namecolor” rowspan=”2″>
NAME
</th>
<th id=”salarycolor” colspan=”3″>
SALARY
</th>
</tr>
<tr>
<th>
BASIC
</th>
<th>
DA
</th>
<th>
HRA
</th>
</tr>
<tr>
<td>
E001
</td>
<td>
A
</td>
<td>
12345
</td>
<td>
2345
</td>
<td>
1239
</td>
</tr>
<tr>
<td>
E002
</td>
<td>
B
</td>
<td>
3212
</td>
<td>
3219
</td>
<td>
7658
</td>
</tr>
</table>
</body>
</html>
style.css
table{
background-color:cyan;position:absolute;right:0
}
tr{
text-align:center
}
#idcolor{
background-color:red;
}
#namecolor{
background-color:green;
}
#salarycolor{
background-color:yellow;
}
1: Validate the fields of a form using JavaScript
SOURCE CODE:
<html>
<head>
<title>1st Javascript</title>
<script language=”javascript”>
function sub()
{
var un = document.getElementById(“user”).value;
var ps = document.getElementById(“pass”).value;
if(un==””||ps==””)
alert(“Some fields are not properly filled out.”);
else
alert(“Username: ” + un +”nPassword: “+ps);
document.getElementById(“myForm”).reset();
}
</script>
</head>
<body>
<label>Username: </label><input type=”text” id=”user”><br><br>
<label>Password: </label><input type=”password” id=”pass”><br><br>
<input type=”submit” value=”SUBMIT” onclick=”sub()”>
</body>
</html>
OUTPUT
2: Implement Exception handling using JavaScript
SOURCE CODE:
<html>
<head>
<script type=”text/javascript”>
<!–
function myFunc()
{
var a = 100;
try {
alert(“Value of variable a is : ” + a );
}
catch ( e ) {
alert(“Error: ” + e.description );
}
}
//–>
</script>
</head>
<body>
<p>Click the following to see the result:</p>
<form>
<input type=”button” value=”Click Me” onclick=”myFunc();” />
</form>
</body>
</html>
OUTPUT
3.Program on Image Roll Over using javascript
SOURCE CODE
<!doctype html>
<html>
<head>
<meta charset=”utf-8″>
<title>How to Make a JavaScript Image Rollover</title>
<!–JavaScript code goes here.–>
<script language=”javascript”>
function MouseRollover(MyImage) {
MyImage.src = “MyPicture2.jpg”;
}
function MouseOut(MyImage) {
MyImage.src = “download.jpg”;
}
</script>
</head>
<body>
<div align=”center”>
<!–The rollover image displays here.–>
<img src=”MyPicture1.jpg” boarder=”0px” width=”650px” height=”550px”
onMouseOver=”MouseRollover(this)”
onMouseOut=”MouseOut(this)” />
</div>
</body>
</html>
OUTPUT
4.Display Clock using Javascript
SOURCE CODE
<html>
<head>
<script>
function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById(‘txt’).innerHTML =
h + “:” + m + “:” + s;
var t = setTimeout(startTime, 500);
}
function checkTime(i) {
if (i < 10) {i = “0” + i}; // add zero in front of numbers < 10
return i;
}
</script>
</head>
<body onload=”startTime()”>
<div id=”txt”></div>
</body>
</html>
OUTPUT
5. Prompt ,Alert , Array, Looping Using javascript
SOURCE CODE(prompt)
<html>
<head>
<title> prompt,alert,variable</title>
</head>
<body>
<script type=”text/javascript”>
var name;
name=prompt(‘enter name’,’name’);
document.writeln(“your name is”+name);
alert(“enter the name sucessfully”);
</script>
</body>
</html>
OUTPUT
SOURCE CODE(alert)
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Alert</h2>
<button onclick=”myFunction()”>Try it</button>
<script>
function myFunction() {
alert(“I am an alert box!”);
}
</script>
</body>
</html>
OUTPUT
SOURCE CODE(LOOPING)
<html>
<head>
<title>while loop</title>
</head>
<body>
<script type=”text/javascript”>
var i;
i=0;
while(i<=5)
{
document.writeln(i);
document.writeln(“<br>”);
i++;
}
</script>
</body>
</html>
OUTPUT
JAVASCRIPT ARRAYS
SOURCE CODE
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Arrays</h2>
<p id=”demo”></p>
<script>
var cars = new Array(“Saab”, “Volvo”, “BMW”);
document.getElementById(“demo”).innerHTML = cars;
</script>
</body>
</html>
OUTPUT
JavaScript Arrays
Saab,Volvo,BMW
5.Calculator Using javascript
SOURCE CODE
<HTML>
<HEAD><TITLE>Calculator</TITLE>
</HEAD>
<BODY>
<CENTER>
<FORM NAME=”Calc”>
<TABLE BORDER=4>
<TR>
<TD>
<INPUT TYPE=”text” NAME=”Input” Size=”16″>
<br>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE=”button” NAME=”one” VALUE=” 1 ” OnClick=”Calc.Input.value += ‘1’”>
<INPUT TYPE=”button” NAME=”two” VALUE=” 2 ” OnCLick=”Calc.Input.value += ‘2’”>
<INPUT TYPE=”button” NAME=”three” VALUE=” 3 ” OnClick=”Calc.Input.value += ‘3’”>
<INPUT TYPE=”button” NAME=”plus” VALUE=” + ” OnClick=”Calc.Input.value += ‘ + ‘”>
<br>
<INPUT TYPE=”button” NAME=”four” VALUE=” 4 ” OnClick=”Calc.Input.value += ‘4’”>
<INPUT TYPE=”button” NAME=”five” VALUE=” 5 ” OnCLick=”Calc.Input.value += ‘5’”>
<INPUT TYPE=”button” NAME=”six” VALUE=” 6 ” OnClick=”Calc.Input.value += ‘6’”>
<INPUT TYPE=”button” NAME=”minus” VALUE=” – ” OnClick=”Calc.Input.value += ‘ – ‘”>
<br>
<INPUT TYPE=”button” NAME=”seven” VALUE=” 7 ” OnClick=”Calc.Input.value += ‘7’”>
<INPUT TYPE=”button” NAME=”eight” VALUE=” 8 ” OnCLick=”Calc.Input.value += ‘8’”>
<INPUT TYPE=”button” NAME=”nine” VALUE=” 9 ” OnClick=”Calc.Input.value += ‘9’”>
<INPUT TYPE=”button” NAME=”times” VALUE=” x ” OnClick=”Calc.Input.value += ‘ * ‘”>
<br>
<INPUT TYPE=”button” NAME=”clear” VALUE=” C ” OnClick=”Calc.Input.value = ””>
<INPUT TYPE=”button” NAME=”zero” VALUE=” 0 ” OnClick=”Calc.Input.value += ‘0’”>
<INPUT TYPE=”button” NAME=”DoIt” VALUE=” = ” OnClick=”Calc.Input.value = eval(Calc.Input.value)”>
<INPUT TYPE=”button” NAME=”div” VALUE=” / ” OnClick=”Calc.Input.value += ‘ / ‘”>
<br>
</TD>
</TR>
</TABLE>
</FORM>
</CENTER>
</BODY>
</HTML>
OUTPUT
6.Phone & Email Validation using javascript
SOURCE CODE
<html>
<head>
<script type=”text/javascript”>
var reg1 = /^(?([0-9]{3}))?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;
var reg2 = /[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}/igm;
function check()
{
var t1=document.getElementById(“t1”).value;
var t2=document.getElementById(“t2”).value;
var OK1 = reg1.exec(t1);
if (!OK1)
window.alert(“phone number isn’t valid”);
else
window.alert(“phone number is valid”);
var OK2 = reg2.exec(t2);
if (!OK2)
window.alert(“Email Id isn’t valid”);
else
window.alert(“Email Id is valid”);
}
</script>
</head>
<body>
<p>Enter your phone number and then press Enter.</p>
<input type=”text” id=”t1″>
<p>Enter your email id and then press Enter.</p>
<input type=”text” id=”t2″>
<input type = “submit” value=”SUBMIT” onclick=”check();”>
<br>
</body>
</html>
OUTPUT
1.Create a banner using Applet
SOURCE CODE
SampleBanner.java
import java.awt.*;
import java.applet.*;
public class SampleBanner extends Applet implements Runnable {
String str = “This is a simple Banner “;
Thread t ;
boolean b;
public void init() {
setBackground(Color.gray);
setForeground(Color.yellow);
}
public void start() {
t = new Thread(this);
b = false;
t.start();
}
public void run () {
char ch;
for( ; ; ) {
try {
repaint();
Thread.sleep(250);
ch = str.charAt(0);
str = str.substring(1, str.length());
str = str + ch;
}
catch(InterruptedException e) {}
}
}
public void paint(Graphics g) {
g.drawRect(1,1,300,150);
g.setColor(Color.yellow);
g.fillRect(1,1,300,150);
g.setColor(Color.red);
g.drawString(str, 1, 150);
}
}
SampleBanner.html
<applet code=”SimpleBanner.class” width=300 height=200>
</applet>
Output
2.Display clock using Applet
SOURCE CODE
ClockApplet.java
import java.awt.*;
import java.applet.*;
import java.applet.*;
import java.awt.*;
import java.util.*;
public class ClockApplet extends Applet implements Runnable {
Thread t, t1;
public void start() {
t = new Thread(this);
t.start();
}
public void run() {
t1 = Thread.currentThread();
while(t1 == t) {
repaint();
try {
t1.sleep(1000);
}
catch(InterruptedException e){}
}
}
public void paint(Graphics g) {
Calendar cal = new GregorianCalendar();
String hour = String.valueOf(cal.get(Calendar.HOUR));
String minute = String.valueOf(cal.get(Calendar.MINUTE));
String second = String.valueOf(cal.get(Calendar.SECOND));
g.drawString(hour + “:” + minute + “:” + second, 20, 30);
}
}
ClockApplet.html
<applet code=”ClockApplet.class” width=300 height=200>
</applet>
OUTPUT
3.Create different shapes using Applet
SOURCE CODE
Shapes.java
import java.applet.*;
import java.awt.*;
public class Shapes extends Applet {
int x = 300, y = 100, r = 50;
public void paint(Graphics g) {
g.drawLine(30,300,200,10);
g.drawOval(x-r,y-r,100,100);
g.drawRect(400,50,200,100);
}
}
Shapes.html
<applet code=”Shapes.class” width=300 height=200>
</applet>
Output
4.Fillcolour in shapes using applet
SOURCE CODE
fillcolor.java
import java.applet.*;
import java.awt.*;
public class fillColour extends Applet{
public void paint(Graphics g){
g.drawRect(300,150,200,100);
g.setColor(Color.yellow);
g.fillRect( 300,150, 200, 100 );
g.setColor(Color.magenta);
g.drawString(“Rectangle”,500,150);
}
}
fill.html
<html>
<applet code=”fillcolour.class” height=200 width=320> No Java?! </applet>
</html>
OUTPUT:-
5.Create an event listener in Applet
SOURCE CODE:
EventListeners.java
import java.applet.*;
import java.awt.event.*;
import java.awt.*;
public class EventListeners extends Applet implements ActionListener{
TextArea txtArea;
String Add, Subtract;
int i = 10, j = 20, sum =0,Sub=0;
public void init(){
txtArea = new TextArea(10,20);
txtArea.setEditable(false);
add(txtArea,”center”);
Button b = new Button(“Add”);
Button c = new Button(“Subtract”);
b.addActionListener(this);
c.addActionListener(this);
add(b);
add(c);
}
public void actionPerformed(ActionEvent e){
sum = i + j;
txtArea.setText(“”);
txtArea.append(“i = “+ i + “t” + “j = ” + j + “n”);
Button source = (Button)e.getSource();
if(source.getLabel() == “Add”){
txtArea.append(“Sum : ” + sum + “n”);
}
if(i >j){
Sub = i – j;
}
else{
Sub = j – i;
}
if(source.getLabel() == “Subtract”){
txtArea.append(“Sub : ” + Sub + “n”);
}
}
}
event.class
<html>
<applet code=” EventListeners.class” height=200 width=320> No Java?! </applet>
</html>
OUTPUT
6.Display image using Applet
SOURCE CODE:
appletImage.java
import java.applet.*;
import java.awt.*;
public class appletImage extends Applet{
Image img;
MediaTracker tr;
public void paint(Graphics g) {
tr = new MediaTracker(this);
img = getImage(getCodeBase(), “Tulips.jpg”);
tr.addImage(img,0);
g.drawImage(img, 0, 0, this);
}
}
applet.html
<html>
<applet code=” appletImage.class” height=200 width=320> No Java?! </applet>
</html>
OUTPUT:-
7.Read a file using Applet
SOURCE CODE:
readFileApplet.java
import java.applet.*;
import java.awt.*;
import java.io.*;
import java.net.*;
public class readFileApplet extends Applet{
String fileToRead = “test1.txt”;
StringBuffer strBuff;
TextArea txtArea;
Graphics g;
public void init(){
txtArea = new TextArea(100, 100);
txtArea.setEditable(false);
add(txtArea, “center”);
String prHtml = this.getParameter(“fileToRead”);
if (prHtml != null) fileToRead = new String(prHtml);
readFile();
}
public void readFile(){
String line;
URL url = null;
try{
url = new URL(getCodeBase(), fileToRead);
}
catch(MalformedURLException e){}
try{
InputStream in = url.openStream();
BufferedReader bf = new BufferedReader
(new InputStreamReader(in));
strBuff = new StringBuffer();
while((line = bf.readLine()) != null){
strBuff.append(line + “n”);
}
txtArea.append(“File Name : ” + fileToRead + “n”);
txtArea.append(strBuff.toString());
}
catch(IOException e){
e.printStackTrace();
}
}
}
read.html
<html>
<applet code=” readFileApplet.class” height=200 width=320> No Java?! </applet>
</html>
OUTPUT
8.Play Sound using Applet
SOURCE CODE
SoundApplet.java
import java.applet.*;
public class SoundApplet extends Applet {
public void init() {
super.init();
resize(0,0);
AudioClip gong = getAudioClip(getDocumentBase(), “gong.au”);
gong.play();
}
}
Play.html
<applet code=”SoundApplet.class” width=300 height=200>
</applet>
OUTPUT
1. Write a XML program that will create an XML document which contains your mailing address.
SOURCE CODE
<mail>
<name>Bum kailash kumar</name>
<address>Ranchi</address>
</mail>
OUTPUT
2.Write a XML program that will create an XML document which contains description of three book category.
SOURCE CODE
<?xml version=”1.0″ encoding=”UTF-8″?>
<bookstore>
<book category=”cooking”>
<title lang=”en”>Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category=”children”>
<title lang=”en”>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category=”web”>
<title lang=”en”>Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
<bookstore>
<book category=”cooking”>
<title lang=”en”>Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category=”children”>
<title lang=”en”>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category=”web”>
<title lang=”en”>Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
OUTPUT
3.Create an XML document that contains the name and price per pound of coffee beans.
SOURCE CODE
<?xml version=”1.0″ encoding=”UTF-8″?>
<coffee_bean>
<coffee_type>
<Coffee_name>Instant Coffee</Coffee_name>
<Price_per_pound>250/-</Price_per_pound>
</coffee_type>
<coffee_type>
<Coffee_name>Special Coffee</Coffee_name>
<Price_per_pound>360/-</Price_per_pound>
</coffee_type>
<coffee_type>
<Coffee_name>Latte</Coffee_name>
<Price_per_pound>420/-</Price_per_pound>
</coffee_type>
</coffee_bean>
OUTPUT
4.Create an XML document that contains airline flight information.
i) In your XML document mention all properties ofXML declaration.
ii) The root element has name <airlines>
iii) Create three nested <carrier> elements for three separate airlines. Each element should include a name attribute.
iv) Within each <carrier> nest at least two <flight> ,each of which contains departure_city, destination_ city, fl_no,
dept_time.
v) Validate the document and if any parsing error is present fix them.
SOURCE CODE
<?xml version=”1.0″ encoding=”UTF-8″?>
<airlines>
<carrier>
<flight>
<departure_city>kolkata</departure_city>
<destination_city>Delhi</destination_city>
<fl_no> AIR4521</fl_no>
<dept_time>10.30A.M.</dept_time>
</flight>
<flight>
<departure_city>Kolkata</departure_city>
<destination_city>Dheradun</destination_city>
<fl_no>AIR4526</fl_no>
<dept_time>14.30P.M.</dept_time>
</flight>
</carrier>
<carrier>
<flight>
<departure_city>Delhi</departure_city>
<destination_city>Mumbai</destination_city>
<fl_no>AIR4529</fl_no>
<dept_time>19.30P.M.</dept_time>
</flight>
<flight>
<departure_city>Delhi</departure_city>
<destination_city>Goa</destination_city>
<fl_no>AIR4559</fl_no>
<dept_time>06.30A.M.</dept_time>
</flight>
</carrier>
<carrier>
<flight>
<departure_city>Goa</departure_city>
<destination_city>Delhi</destination_city>
<fl_no>AIR4586</fl_no>
<dept_time>15.30P.M.</dept_time>
</flight>
<flight>
<departure_city>Mumbai</departure_city>
<destination_city>Delhi</destination_city>
<fl_no>AIR4556</fl_no>
<dept_time>17.30P.M.</dept_time>
</flight>
</carrier>
</airlines>
OUTPUT
5. :Create an XML version of your resume. Include elements such as your name and position desired. Nest each of your former employers within an <employer> element. Also, nest your educational experience within an <education> element. Create any other nested elements that you deem appropriate, such as <references> or <spcl_skills> elements.
SOURCE CODE
<resume>
<personal_information>
<name>BUM KAILASH KUMAR</name>
<phn_no>+91-8709063071</phn_no>
<email>bumkailashkumar@gmail.com</email>
<post_applying_for>Software Engineer</post_applying_for>
</personal_information>
<education>
<secondary>
<school>Sri guru nanak public school</school>
<board>CBSE</board>
<percentage>63%</percentage>
</secondary>
<higher_secondary>
<school>INDIRA GANDHI SRACMIC INTER COLLEGE</school>
<board>JAC</board>
<percentage>53%</percentage>
</higher_secondary>
<graduation>
<college>BBIT</college>
<board>MAKAUT</board>
<percentage>65%</percentage>
</graduation>
</education>
<special_skill>
<language>
<language1> English</language1>
<language2> Hindi</language2>
</language>
<programming_language>C,C++,Java</programming_language>
</special_skill>
</resume>
OUTPUT
6. Create a DTD on product catalog.
SOURCE CODE:
<Item>
<Item1>
<ItemName>Computer</ItemName>
<Price>25000/-</Price>
<Specification>Core-i3</Specification>
</Item1>
<Item2>
<ItemName>Laptop</ItemName>
<Price>64000/-</Price>
<Specification>Core-i7</Specification>
</Item2>
<Item3>
<ItemName>HTC-Smart Phone</ItemName>
<Price>13000/-</Price>
<Specification>Lollipop</Specification>
</Item3>
</Item>
OUTPUT