Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
E-Commerce/Java/C++
STREAM : B.Com
1. Create a web page with the following using HTML :
i) To embed an image map in a web page
ii) To fix the hot spots
iii) Show all the related information when the hot spots are clicked.
2. Create a web page with all types of Cascading style sheets
3. Client Side Scripts for Validating Web Form Controls using DHTML.
4. Write programs in Java to create applets incorporating the following features: Create a
color palette with matrix of buttons Set background and foreground of the control text
area by selecting a color from color palette. In order to select Foreground or background
use check box control as radio buttons To set background images
5. Write programs in Java using Servlets:
i) To invoke servlets from HTML forms
ii) To invoke servlets from Applets
6. Write programs in Java to create three- tier applications using JSP and Databases for
conducting on-line examination, for displaying student mark list. Assume that student
information is available in a database which has been stored in a database server.
7. Programs using XML - Schema - XSLT/XSL
8. Program using DOM / SAX
9. Programs using AJAX
10. Consider A Case Where We Have Two Web Services An Airline Service And A Travel
Agent And The Travel Agent Is Searching For An Airline. Implement This Scenario Using
Web Services And Data Base.
1.Create a web page with the following using HTML
i) To embed an image map in a web page
ii) To fix the hot spots
iii) Show all the related information when the hot spots are checked
AIM:
To create a web page with embed an image map and to with hot spots and related
information when hotspots are c licked.
ALGORITHM:
PROGRAM CODING:
(EXP1.HTML)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<head>
<title>Tamilnadu map</title>
</head>
<body bgcolor="white" text="Black">
<p>
<i>
<font size="45">
Tamilnadu state map
</font>
</i>
</p>
<map name="tamilnadu" align="middle">
<area href="kovai.html" shape="rect" coords="320,334,190,282">
<area href="Thrichy.html" shape="rect" coords="520,150,160,382">
<area href="madurai.html" shape="rect" coords="680,488,190,280">
<area href="http://en.wikipedia.org/wiki/Chennai" shape="rect" coords="700,40,190,100">
</map>
<img src="TN.02.jpg"
usemap="#tamilnadu" align="middle">
</body>
</html>
(KOVAI.HTML)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<head>
<title>kovai district map</title>
</head>
<body text="black">
<img src="coimbatore.jpg">
<p>
<font size="3.9">
Coimbatore, also known as Kovai,it is the second largest city in the Indian state of </p>
<p>Tamil Nadu and the 15th largest urban agglomeration in India with a metropolitan population
of</p><p> over 2 million.It is the second largest urban agglomeration in the
state.</p></font></p>
</body>
</html>
(MADURAI.HTML)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<head>
<title>Madurai</title>
</head>
<body text="black">
<img src="madurai_map.jpg" align="middle">
<font size="4">
<p>Madurai is the administrative headquarters of Madurai<p> District
in the South Indian state of Tamil Nadu.</p> It is the third largest city
in Tamilnadu next to Chennai and Coimbatore and the <p>second largest
municipal corporation in Tamil Nadu next only to Chennai.It is the
most important city in Tamil Nadu state after Chennai and Coimbatore
respectively.</p> It is the capital of Tamil Nadu by administration
headquarters of southern districts in Tamil Nadu.<p>Located on the
banks of River Vaigai, it has been a major settlement for over two millennia.
</p>
</font>
</body>
</html>
(TRICHY.HTML)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<head>
<title>Trichy</title>
</head>
<body text="black">
<img src="trichy mpa.jpg">
<font size="4">
<p>Tiruchirappalli also called Tiruchi or Trichy, is a city in the</p> <p> Indian state of Tamil
Nadu and the administrative headquarters of Tiruchirappalli District.</p> <p> It is the Fourth
largest municipal corporation in Tamil Nadu and also the Fourth largest urban agglomeration in
the state.
</p>
</font>
</body>
</html>
OUTPUT:
TRICHY.HTML
RESULT:
Thus web page with embed an image map and with hot spots and related information
are successfully created.
2.Create a web page with all types of Cascading style sheets.
AIM:
To create a web page by using external as well as internal style sheets.
ALGORITHM :
Step 1: Create a HTML page with necessary DOC TYPE.
Step 3: Create a internal style sheet in the head using style tag,
Step 4: Call the external style sheet file XYZ.CSS using link real attribute.
Step 5: In the body tag ,using the style sheet class give the contents.
Step 8: Close.
PROGRAM CODING:
(XYZ.CSS)
h3{font_family:arial;font_size:20;color:cyan}
table{border_color:green}
td{font_size;20pt;color:magenta}
(EXP2.HTML)
<html>
</title>
<style type="text/css">
.vid{font_family:verdana;font_style:italic,color:red;text_align:center}
.ani{font_family:tahoma;font_style:italic;font_size:20;text_align:center;}
font{font_family:georgia;color:blue;font_size:20}
ul{list_style_type:circle}
</style>
</head>
<body>
</ol>
<br>
<br>
<font>
<ul>
</ul>
</font>
<table width="100%"cellspacing="2"cellpadding="2"border="5">
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
</table>
</body>
</html>
OUTPUT:
RESULT:
Thus we created a web page by using as well as internal style sheets and successfully
executed.
3.Client Side Scripts for validating Web Forms Controls using DHTML.
AIM:
Create a client side script for validatinig web form controls usiing HTML.
ALGORITHM:
Step 1: Create a html page using script tag.
Step 2: Define the function validate and define all the validation opearation.
Step 3: Produce the alert message on incomplete submission and also for complete
Submission.
Step 4: In the body attribute tag define background font colors and font style.
Step 5: Create the input type label as a name,depart and id number.
Step 6: Fix the range of the id number as input using max length.
Step 7: On clciking the submit button the validating form function will invoke.
Step 8: Execute the html code in internet explorer on any of the browser.
PROGRAM CODING:
<html>
<head>
<title>validation checking </title>
</head>
<script language="javascript"> function passwordStrength(password)
{
var str1="strong"; var str2="weak";
if (password.length > 6)
document.getElementById("passwordDescription").innerHTML =str1; else
document.getElementById("passwordDescription").innerHTML =str2;
}
function a()
{
var i=document.form1.uname.value; var a=i.length;
var j=document.form1.pass.value; var b=j.length;
if(a==0&&b==0)
window.alert("Enter username and password"); else
{
if(a==0)
window.alert("Enter username "); if(b==0)
window.alert("Enter password");
}
if(a!=0&&b!==0&&b<7) window.alert("password is too short");
}
</script> <body>
<form name="form1" >
<font color="red"><marquee>WEBSITE MODERATORS : </marquee></font>
<br> <br>
UserName:<input type="text" name="uname">@india.com <br>
Password: <input type="password" name="pass"
onkeyup="passwordStrength(this.value)">
<label >Password strength:</label><label id="passwordDescription" >password not
entered</label> <p><h6>Minimum of 7 characters in length.</h6></p> <br>
Powered By www.technoscriptz.com
&n
bsp;
<input type="button" value="Submit" onclick="a()">
</form>
</body>
OUTPUT:
RESULT:
Thus we created a client side script for validating web form controls using DHTML.
4.Write programs in java to create applet incorporating following features:
Create a color palette with matrix of buttons , set background and foreground of
the control text area by selecting a color from color palette. In order to select
foreground or background use check box control as radio buttons , to set
background images.
AIM:
To write programs in java to create applets incorporating the following features.
i) Create a color palette with matrix of buttons.
ii) Set background and foreground of the control text area by selecting a color from color
palette.
iii) In order to select foreground and background use checkbox control as radio button.
ALGORITHM:
Step 2: Initialize the applet code with height as 800 and width as 300.
Step 3: Extend applet/code with height as 800 and width as 300 which implements
ItemListener
Step 4: Initialize the six buttons with red , blue , green , yellow , magenta and white.
PROGRAM CODING:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*<applet code="exp" width=400 height=400>
</applet>*/
public class exp extends Applet implements ItemListener
{
int currcolor=5;
int flag=1;
String text="Click any of the buttons";
Button buttons[]=new Button[5];
String colours[]={"Red","Blue","Green","Yellow","Magenta"};
Image img;
CheckboxGroup cbg=new CheckboxGroup();
Checkbox box1=new Checkbox("Background Color",cbg,true);
Checkbox box2=new Checkbox("Text Color",cbg,false);
Checkbox box3=new Checkbox("Loading Image",cbg,false);
public void init()
{
for(int i=0;i<5;i++)
{
buttons[i]=new Button(" ");
add(buttons[i]);
}
buttons[0].setBackground(Color.red);
buttons[1].setBackground(Color.blue);
buttons[2].setBackground(Color.green);
buttons[3].setBackground(Color.yellow);
buttons[4].setBackground(Color.magenta);
add(box1);
add(box2);
add(box3);
box1.addItemListener(this);
box2.addItemListener(this);
box3.addItemListener(this);
}
public void itemStateChanged(ItemEvent ev)
{
if(box1.getState()==true)
flag=1;
else if(box2.getState()==true)
{
text="Default color is black";
flag=2;
}
else if(box3.getState()==true)
{
img=getImage(getDocumentBase(),"Blue hills.jpg");
flag=3;
}
repaint();
}
public void paint(Graphics g)
{
if(flag==2)
{
g.drawString(text,30,100);
switch(currcolor)
{
case 0:
g.setColor(Color.red);
break;
case 1:
g.setColor(Color.blue);
break;
case 2:
g.setColor(Color.green);
break;
case 3:
g.setColor(Color.yellow);
break;
case 4:
g.setColor(Color.magenta);
break;
case 5:
g.setColor(Color.black);
break;
}
g.drawString(text,30,100);
}
else if(flag==1)
{
g.drawString(text,30,100);
switch(currcolor)
{
case 0:
setBackground(Color.red);
break;
case 1:
setBackground(Color.blue);
break;
case 2:
setBackground(Color.green);
break;
case 3:
setBackground(Color.yellow);
break;
case 4:
setBackground(Color.magenta);
break;
case 5:
setBackground(Color.white);
break;
}
}
else if(flag==3)
{
g.drawImage(img,20,90,this);
}
}
public boolean action(Event e,Object o)
{
for(int i=0;i<5;i++)
{
if(e.target==buttons[i])
{
currcolor=i;
text="You have chosen "+colours[i];
repaint();
return true;
}
}
return false;
}
}
OUTPUT:
RESULT:
Thus the java program for color palette, with background, foreground and to set
background images is creates and executed successfully.
5.Write programs in java using servlets:
i) To invoke servlets from HTML forms
AIM:
ALGORITHM:
client.html
Step 1: Create a web page using HTML form that contains the fields such as text,
password
and one submit button.
Step 2: Set the URL of the server as the value of form’s action attribute.
Step 3: Run the HTML program.
Step 4: Submit the form data to the server.
server.java
Step 1: Define the class server that extends the property of the class GenericServlet.
Step 2: Handle the request from the client by using the method service() of
GenericServlet
class.
Step 3: Get the parameter names from the HTML form by using the method
getParameterNames().
Step 4: Get the parameter values from the HTML forms by using the method
getParameter().
Step 5: Send the response to the client by using the method of PrintWriter class.
PROGRAM CODING:
Servlethtml.HTML
<html>
<head>
</head>
<body bgcolor="violet">
<fieldset>
<legend>Registration</legend>
Enter E-mail :
<input type="text" name="LoginID" size="25"/><br/><br/>
Enter Password:
</fieldset>
</form>
</body>
</html>
Server.java
import java.io.*;
import java.util.*;
import javax.servlet.*;
PrintWriter pw=res.getWriter();
pw.print("<h3>Registration Successful...</h3>");
Enumeration e=req.getParameterNames();
while(e.hasMoreElements())
String str1=(String)e.nextElement();
String str2=req.getParameter(str1);
pw.print(str1+"="+str2+"<br/>");
}
pw.close();
Web.xml
servlet>
<servlet-name>server</servlet-name>
<servlet-class>server</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>server</servlet-name>
<url-pattern>/servlet/server</url-pattern>
</servlet-mapping>
Output:
Result:
Thus the program for invoking servlets from html file was successfully executed..
ii) To invoke servlets from Applet
AIM:
ALGORITHM:
PROGRAM CODING:
Applet.html
<html>
<head>
<title>Invoking Servlets From Applet</title>
</head>
<body bgcolor="violet">
<applet code="AppletClient.class" width="400" height="200">
</applet>
</body>
</html>
AppletClient.java
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
public class AppletClient extends Applet implements ActionListener
{
public void init()
{
Label la=new Label("INVOKING SERVLET FROM APPLET");
la.setFont(new Font("Courier",Font.BOLD,15));
la.setForeground(Color.blue);
add(la);
Button b1=new Button("Click Here To Display Date Information From Server");
b1.setBackground(Color.black);
b1.setForeground(Color.white);
add(b1);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
try
{
AppletContext ac=getAppletContext();
URL url = new URL("http://localhost:8080/servlet/MyServer");
ac.showDocument(url);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
MyServer.java
import java.io.*;
import java.util.*;
import javax.servlet.*;
public class MyServer extends GenericServlet
{
public void service(ServletRequest req,ServletResponse res)throws
ServletException,IOException
{
PrintWriter pw=res.getWriter();
Date d=new Date();
pw.println("<html><body bgcolor=blue><h2>Server Response</h2>");
pw.println("<h3>Current Date and Time From Server:</h3>");
pw.println("<b>"+d+"</b></body></html>");
}
}
Web.xml
<servlet>
<servlet-name>AppletClient</servlet-name>
<servlet-class>MyServer</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AppletClient</servlet-name>
<url-pattern>/servlet/MyServer</url-pattern>
</servlet-mapping>
OUTPUT:
RESULT:
Thus the program for invoking servlets from applet was successfully executed..
6. THREE TIER APPLICATION
AIM:
For displaying the student mark list. Assume student information is available in a
database which
ALGORITHM:
PROGRAM:
HomePage.html
<%
String SeatNum,Name;
String ans1,ans2,ans3,ans4,ans5;
int a1,a2,a3,a4,a5;
a1=a2=a3=a4=a5=0;
Connection connect=null;
Statement stmt=null;
ResultSet rs=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
if(request.getParameter("action")!=null)
SeatNum = request.getParameter("Seat_no");
Name = request.getParameter("Name");
ans1 =request.getParameter("group1");
if(ans1.equals("True"))
a1=2;
else
a1=0;
ans2 = request.getParameter("group2");
if(ans2.equals("True"))
a2=0;
else
a2=2;
ans3 = request.getParameter("group3");
if(ans3.equals("True"))
a3=0;
else
a3=2;
ans4 = request.getParameter("group4");
if(ans4.equals("True"))
a4=2;
else
a4=0;
ans5 = request.getParameter("group5");
if(ans5.equals("True"))
a5=0;
else
a5=2;
int Total=a1+a2+a3+a4+a5;
stmt = connect.createStatement();
stmt.close();
stmt = connect.createStatement();
rs = stmt.executeQuery(query);
%>
<body bgcolor=khaki>
<center>
<h2>Students Marksheet</h2>
<tr>
<td><b>Seat_No</b></td>
<td><b>Name</b></td>
<td><b>Marks</b></td>
</tr>
<%
while(rs.next())
%>
<tr>
<td><%=rs.getInt(1)%></td>
<td> <%=rs.getString(2)%></td>
<td> <%=rs.getString(3)%></td>
</tr>
<%
rs.close();
stmt.close();
connect.close();
%>
</table>
</center>
<br/> <br/><br/>
<table>
</table>
<div>
</body>
</html>
<%}else{%>
<html>
<head><title>Online Examination</title>
<script language="javascript">
function validation(Form_obj)
{
if(Form_obj.Seat_no.value.length==0)
Form_obj.Seat_no.focus();
return false;
if(Form_obj.Name.value.length==0)
Form_obj.Name.focus();
return false;
return true;
</script>
</head>
<body bgcolor=lightgreen>
<center>
<h1>OnLine Examination</h1>
</center>
<table>
<tr>
<td><h3>Seat Number:</h3></td>
</tr>
<tr>
<td><h3>Name:</h3></td>
</tr>
<hr/>
<tr>
<td></td><td></td><td></td><td><b>Time: 15 Min.</b></td>
</tr>
</table>
<hr/>
<br/>
<br/>
<br/>
<br/>
<b>5. HTTP is a statefull protocol</b><br/>
<hr/>
<center>
</center>
</form>
<%}%>
OUTPUT:
RESULT:
Thus the Web page using JSP has been executed successfully.
To write a XSL program for converting the given XML document into equivalent
XHTML.
ALGORITHM:
STEP 3: write a XSL program that contains the XSL elements for converting into
XHTML file
STEP 4: Insert the following tag in the second line of the XML file
<?xml-stylesheet type="text/xsl" href="7thexp.xsl"?>
PROGRAM
7thexp.xml
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>two of our famous Belgian Waffles with plenty of real maple syrup</description>
<calories>650</calories>
</food>
<food>
<price>$7.95</price>
<calories>900</calories> </food>
<food>
<price>$8.95</price>
<description>light Belgian waffles covered with an assortment of fresh berries and whipped
cream</description>
<calories>900</calories>
</food>
<food>
<name>French Toast</name>
<price>$4.50</price>
<calories>600</calories>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>two eggs, bacon or sausage, toast, and our ever-popular hash browns</description>
<calories>950</calories>
</food>
</breakfast_menu>
7thexp.xsl
OUTPUT
RESULT:
Thus the program for converting the XML into XHTML file using the XSLT
executed successfully.
ALGORITHM
STEP 1: Start the program.
STEP 3: Write a DOM Parser program using java by including the necessary
package.
STEP 4: Execute the java program by including the XML file as an argument.
STEP 5: Write a SAX Parser program using java by including the necessary
package.
STEP 6: Execute the java program by including the XML file as an argument.
PROGRAM
colorfile.xml
<?xml version="1.0"?>
<!DOCTYPE shapes [
<!ELEMENT shapes (circle)*>
<!ELEMENT circle (x,y,radius)>
<!ELEMENT x (#PCDATA)>
<!ELEMENT y (#PCDATA)>
<!ELEMENT radius (#PCDATA)>
<!ATTLIST circle color CDATA #IMPLIED>
]>
<shapes>
<circle color="BLUE">
<x>20</x>
<y>20</y>
<radius>20</radius>
</circle>
<circle color="RED" >
<x>40</x>
<y>40</y>
<radius>20</radius>
</circle>
</shapes>
//program using DOM parser.
import java.io.*;
import org.w3c.dom.*;
import org.apache.xerces.parsers.DOMParser;
public class shapes_DOM {
static int numberOfCircles = 0; // total number of circles seen
static int x[] = new int[1000]; // X-coordinates of the centers
static int y[] = new int[1000]; // Y-coordinates of the centers
static int r[] = new int[1000]; // radius of the circle
static String color[] = new String[1000]; // colors of the circles
try{
// create a DOMParser
DOMParser parser=new DOMParser();
parser.parse(args[0]);
}
// print the result
System.out.println("circles="+numberOfCircles);
for(int i=0;i<numberOfCircles;i++) {
String line="";
line=line+"(x="+x[i]+",y="+y[i]+",r="+r[i]+",color="+color[i]+")";
System.out.println(line);
}
}
}
OUTPUT
// main method
public static void main(String[] args) {
try{
shapes_SAX SAXHandler = new shapes_SAX (); // an instance of this class
SAXParser parser=new SAXParser(); // create a SAXParser object
parser.setContentHandler(SAXHandler); // register with the ContentHandler
parser.parse(args[0]);
} catch (Exception e) {e.printStackTrace(System.err);} // catch exeptions
}
OUTPUT
RESULT
Thus the XML program is parsed and executed using DOM parser and SAX parser
separately.
AIM:
STEP 2: Write a program using html that includes the necessary tags and java
script function and object (XMLHttpRequest)
STEP 3: Update the web page using the content given in an input file.
PROGRAM:
<html>
<head>
<script type="text/javascript">
function loadXMLDoc()
if (window.XMLHttpRequest)
xmlhttp=new XMLHttpRequest();
else
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange=function()
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
xmlhttp.open("GET","ajax_info.txt",true);
xmlhttp.send();
</script>
</head>
<body>
</body>
</html>
OUTPUT:
//output1
//output2
RESULT:
10. Consider a case where we have two web Services an airline service and a travel
agent and the travel agent is searching for an airline. Implement this scenario using
Web Services and Data base.
AIM:
To create an airline reservation service and a travel agent and the travel agent is
searching for an airline using webservices and database
ALGORITHM:
Step 5: Stop
Program:
<?xml version = "1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- Airline Reservation System-->
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title>Airline Reservation System</title>
<script type = "text/javascript">
<!-- var input;
var secondInput;
var element;
var secondElement;
var firstCount = 0;
var economyCount = 0;
var seats = [ ,0,0,0,0,0,0,0,0,0,0]; //allocate 10-element Array
function startArray()
{
for(var i=0; i<11; i++)
{
input = window.prompt("Please type 1 for First Class and Please type 2 for
Economy.","0");
if (input == 1 || input == 2)
{
element = linearSearch(seats);
if (element==-1 && input == 1)
{
document.writeln("The First Class is already fully booked<br/>");
secondQuestion(seats);
}
else if (element ==-1 && input == 2)
{
document.writeln("The Economy Class is already fully booked<br/>");
secondQuestion(seats);
}
else
boardingPass(input);
} //to terminate the program
else
{
window.status = "Bye-bye!";
System.exit(0);
}}}
function linearSearch(theArray)
{
if (input == 1)
{
for (var n=0; n<6 ; n++)
if (theArray [n] == 0)
return n;
}
else if (input == 2)
{
for (var n=6; n<11 ; n++)
if (theArray [n] == 0)
return n;
}
return -1;
}
function boardingPass(theInput)
{
if (input ==1)
{
document.writeln("----------BOARDING PASS----------<br/>");
document.writeln("You are allocated in the First Class<br/>");
document.writeln("Your seat number is "+ element+"<br/>");
document.writeln("-----------------------------------------<br/>"); seats[element]= 1;
firstCount++;
}
else if (input ==2)
{
document.writeln("----------BOARDING PASS----------<br/>");
document.writeln("You are allocated in the Economy Class<br/>");
document.writeln("Your seat number is "+ element +"<br/>");
document.writeln("-----------------------------------------<br/>");
seats[element]= 1;
economyCount++;
}
}
function secondQuestion(theArray)
{
if (input == 1)
{
for (var n=6; n<11 ;n++)
{
if (theArray [n] == 0)
{
secondInput = window.prompt("Do you want to move to Economy Class? (If YES,
please press 1. If NO, please press 2)","0");
if ( secondInput == 1)
{
input = 2;
element=linearSearch(seats);
document.writeln("You have been allocated to Economy Class<br/>");
boardingPass(input);
break;
}
else if (secondInput == 2)
{ document.writeln("Next flight leaves in 3 hours<br/>");
break;
} }}
}
else if (input == 2)
{
for (var n=0; n<6 ;n++)
{
if (theArray [n] == 0)
{
secondInput = window.prompt("Do you want to move to First Class? (If YES, please
press 1. If NO, please press 2)","0");
if ( secondInput == 1)
{
input = 1;
element=linearSearch(seats);
document.writeln("You have been allocated to First Class<br/>");
boardingPass(input);
break;
}
else if (secondInput == 2)
{
document.writeln("Next flight leaves in 3 hours<br/>");
break;
} }}}
}
//-->
</script>
</head>
<body onload = "startArray()"></body>
</html>
Output
Result:
The web service for the required application is created.
C++
1. Write a Program in C# to Check whether a number is Palindrome or not.
using System;
class palindrome
int num=0,rev,num1=0,num2=0;
Console.WriteLine("Enter a number");
num=int.Parse(Console.ReadLine());
num2=num;
while(num>0)
rev=num%10;
num=num/10;
num1=num1*10+rev;
if(num1==num2)
Console.WriteLine("Number is Palindrome");
else
using System;
class cmdarg
{
int num=0;
String[] argument=Environment.GetCommandLineArgs();
for(int i=1;i<argument.Length;i++)
num=num+int.Parse(argument[i]);
using System;
a = double.Parse(Console.ReadLine());
b = double.Parse(Console.ReadLine());
c = double.Parse(Console.ReadLine());
d = Math.Sqrt(b * b - 4 * a * c);
if (d == 0)
Console.WriteLine("The Roots for the given Equation are Real and Equal");
r1 = r2 = -b / (2 * a);
else if (d < 0)
r2 = (-b - d) / (2 * a);
else
n = -b / (2 * a);
class Quad
r.input();
class demo
Console.WriteLine("value" + obj);
Object o;
int a = 10;
double d = 4.4;
o = a; //boxing integer
Console.WriteLine("Passing integer");
box(a);
Console.WriteLine("Passing Object");
box(o);
int x = (int)o;//Unboxing
Console.WriteLine("Unboxing");
Console.WriteLine("a=" + x);
o = d; //boxing double
Console.WriteLine("Passing double");
box(d);
Console.WriteLine("Passing Object");
box(o);
Console.WriteLine("Unboxing");
Console.WriteLine("d=" + dd);
}
5. Write a Program in C# to implement Stack operations.
using System;
class stack
int top;
int[] s;
s = new int[size];
top = -1;
public stack() { }
if (top == -1)
return;
top--;
s[++top] = var;
return;
Console.WriteLine(s[i]);
//st.init();
int eflag = 0;
do
Console.WriteLine("1. Push");
Console.WriteLine("2. Pop");
Console.WriteLine("3. Display");
Console.WriteLine("4. Exit\n\n");
int ch = int.Parse(Console.ReadLine());
switch (ch)
st.push(var);
break;
case 2: st.pop();
break;
case 3: st.display();
break;
case 4: eflag=1;
break;
} while (eflag==0);
using System;
class OLoad
int var1,var2;
var1=a;
var2=b;
public OLoad()
}
public static OLoad operator + (OLoad op1,OLoad op2)
class OLoadMain
op1++;
op2++;
op3=op1+op2;
op3=op1-op2;
}
7. Write a Program in C# to find the second largest element in a single dimensional array.
using System;
class SLar
int size;
int[] nums;
public SLar(int n)
nums=new int[size=n];
nums[i] = int.Parse(Console.ReadLine());
lar = nums[0];
sec = nums[1];
sec = lar;
lar = nums[i];
if ((sec < nums[i] && nums[i] > lar || (nums[i] != lar && sec == lar)))
sec = nums[i];
}
if(sec==lar)
return -1;
else
return sec;
class SLarMain
s.input();
using System;
class MatMulti
int r1,r2,c1,c2;
a=new double[(this.r1=r1),(this.c1=c1)];
b=new double[(this.r2=r2),(this.c2=c2)];
c=new double[r1,c2];
if(c1==r2)
{
for(int i=0;i<r1;i++)
for(int j=0;j<c1;j++)
a[i,j]=double.Parse(Console.ReadLine());
for(int i=0;i<r2;i++)
for(int j=0;j<c2;j++)
b[i,j]=double.Parse(Console.ReadLine());
for(int i=0;i<r1;i++)
for(int j=0;j<c2;j++)
c[i,j]=0;
for(int k=0;k<r2;k++)
c[i,j]+=a[i,k]*b[k,j];
Console.WriteLine("First matrix");
for(int i=0;i<r1;i++)
for(int j=0;j<c1;j++)
Console.Write(a[i,j]+" ");
Console.WriteLine();
Console.WriteLine("Second matrix");
for(int i=0;i<r2;i++)
{
for(int j=0;j<c2;j++)
Console.Write(b[i,j]+" ");
Console.WriteLine();
for(int i=0;i<r1;i++)
for(int j=0;j<c2;j++)
Console.Write(c[i,j]+" ");
Console.WriteLine();
else
class MultiImpl
int a,b,c,d;
a=int.Parse(Console.ReadLine());
b=int.Parse(Console.ReadLine());
c=int.Parse(Console.ReadLine());
d=int.Parse(Console.ReadLine());
m.Multiply();
}
9. Find the sum of all the elements present in a jagged array of 3 inner arrays.
using System;
int sum = 0;
arr[i][j] = int.Parse(Console.ReadLine());
sum += arr[i][j];
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RevStr
public StrRev(string s)
str1 = s;
str2 = str2 + s;
return str2;
s1 = Console.ReadLine();
s2 = sr.Reverse();
11. Using Try, Catch and Finally blocks write a program in C# to demonstrate error handling.
using System;
class ExceptionDemo
int a = 1, b = 0, c;
try
c = a / b;
try
arr[3] = 5;
finally
using System;
namespace SimpleCalc
class Calc
private float a, b, c;
char op;
this.a = a;
this.b = b;
this.op = op;
try
else
switch (op)
try
c = a / b;
catch (ArithmeticException e)
Console.WriteLine("Denomination zero");
} break;
default: break;
catch (opchck o)
Console.WriteLine(o);
: base(msg)
public opchck()
char ch;
do
float a = float.Parse(Console.ReadLine());
char op = char.Parse(Console.ReadLine());
float b = float.Parse(Console.ReadLine());
c.Calculator();
ch = char.Parse(Console.ReadLine());
//Console.ReadLine();
13. Demonstrate Use of Virtual and override key words in C# with a simple Program
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Virtualnride
class Bird
Console.WriteLine("Name=" + name);
Console.WriteLine("Type=" + type);
//base.setfun();
name = "Indianswift";
Console.WriteLine("Name=" + name);
Console.WriteLine("Type=" + type);
class Program
o1.setfun();
o1.display();
FlyingBird o2 = new FlyingBird();
o2.setfun();
o2.display();
Console.ReadLine();
14. Implement linked lists in C# using the existing collections name space.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace LinkedList
public MyLinked()
if (checkpos(pos))
arr.Insert(pos, value);
{
arr.Add(val);
return false;
else
return true;
if (arr.Count == 0)
Console.WriteLine("list empty");
return false;
return true;
arr.RemoveAt(pos);
else
arr.Remove(val);
else
arr.CopyTo(a);
if (checkLen())
Console.WriteLine(i);
arr.Clear();
while (true)
String ch = Console.ReadLine();
switch (ch)
case "1":
l.add(val);
break;
case "2":
val = int.Parse(Console.ReadLine());
pos = int.Parse(Console.ReadLine());
break;
case "3":
if (l.checkLen())
pos = int.Parse(Console.ReadLine());
l.remove(pos - 1);
break;
case "4":
if (l.checkLen())
val = int.Parse(Console.ReadLine());
l.delete(val);
break;
case "5":
l.show();
break;
case "6":
l.clearAll();
break;
case "7":
Environment.Exit(0);
break;
default: break;
15. Write a program to demonstrate abstract class and abstract methods in C#.
using System;
namespace Abstract
public Motorcycle()
this.Wheels = 2;
public Motorcycle(string s)
this.Wheels = 2;
this.Name = s;
Console.WriteLine("This motor cycle name is " + this.Name + " and its price is " +
this.Amount);
public Car()
this.Wheels = 4;
this.Wheels = 4;
this.Name = s;
this.EngineType = t;
Console.WriteLine("This car name is " + this.Name + " has engine type " + this.EngineType
+ " and price " + this.Amount);
Vehicle v;
//m.Calculate();
//c.Calculate();
v = m;
v.Calculate();
v = c;
v.Calculate();
Console.ReadLine();
16. Write a program in C# to build a class which implements an interface which is already
existing.
using System;
public MyClone()
data1 = 0;
data2 = "";
data1 = d1;
data2 = d2;
ob.data1 = data1;
ob.data2 = data2;
return ob;
return str;
class Demo
MyClone b = (MyClone)a.Clone();
Console.ReadLine();
using System;
class student
}
public string name
this.usn = usn;
s.name = "Sharath";
s.percentage = 79.0;
s.show();
namespace InterfaceArray
void Calculate();
void Display();
public Rectangle()
this.Length = 0;
this.Breadth = 0;
this.Length = l;
this.Breadth = b;
}
public class Circle : IShape
public Circle()
this.Radius = 0;
public Circle(double s)
this.Radius = s;
s[i].Calculate();
s[i].Display();
Console.ReadLine();
}