0% found this document useful (0 votes)
3 views

6 sem practical

The document contains multiple code snippets in Visual Basic and C# that demonstrate various programming concepts, including event handling, string manipulation, and mathematical operations. Each slip represents a different functionality, such as addition, palindrome checking, and salary calculations. The code is structured in a way that showcases the use of classes, methods, and user interface elements.

Uploaded by

rohinikapur8624
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

6 sem practical

The document contains multiple code snippets in Visual Basic and C# that demonstrate various programming concepts, including event handling, string manipulation, and mathematical operations. Each slip represents a different functionality, such as addition, palindrome checking, and salary calculations. The code is structured in a way that showcases the use of classes, methods, and user interface elements.

Uploaded by

rohinikapur8624
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

❖ Slip: 1 }

Public Class Form1 void add()


DimnoAsInteger = 0 {
Private Sub Button1_Click(ByVal sender As int a, b, c;
System.Object, ByVal e As System.EventArgs) Console.WriteLine("Enter two numbers:");
Handles Button1.Click a =Convert.ToInt32(Console.ReadLine());
no = no + 5 b =Convert.ToInt32(Console.ReadLine());
TextBox1.Text = no c = a + b;
End Sub Console.WriteLine("addition is:" + c);
EndClass Console.ReadLine();
}
Slip: 2 }
Public Class Form1 }
Dimflag As Integer = 0
Private Sub Timer1_Tick(ByVal sender As Object, Slip: 4
ByVal e As EventArgs) Handles Timer1.Tick Public Class Form1
If flag = 0 Then Private Sub Button1_Click(ByVal sender As
Label1.Left = Label1.Left + 10 System.Object, ByVal e As System.EventArgs)
Else Handles Button1.Click
Label1.Left = Label1.Left- 10 DimdAsDate
End If d = DateTimePicker1.Value
If Label1.Left >= Me.Width Then TextBox1.Text = d.Day
flag = 1 TextBox2.Text = d.Month
End If TextBox3.Text = d.Year
If Label1.Left <= 0 Then End Sub
flag = 0 EndClass
End If
End Sub Slip: 5
Private Sub Button1_Click(ByVal sender As Public Class Form1
System.Object, ByVal e As System.EventArgs) Private Sub TextBox1_KeyPress(ByVal sender As
Handles Button1.Click System.Object, ByVal e As
Timer1.Enabled = True System.Windows.Forms.KeyPressEventArgs)
End Sub Handles TextBox1.KeyPress
Private Sub Button2_Click(ByVal sender As Dim ch As Char
System.Object, ByVal e As System.EventArgs) Dim str As String
Handles Button2.Click ch = e.KeyChar
Timer1.Enabled = False If (TextBox1.Text.Length <= 1) Then
End Sub If Char.IsUpper(ch) Then
EndClass str = "Upper Case"
Else
Slip: 3 str = "Lower Case"
using System; End If
using System.Collections.Generic; If (ch = "a" Or ch = "e" Or ch = "i" Or ch = "o" Or
using System.Linq; ch = "u" Or
using System.Text; ch = "A" Or ch = "E" Or ch = "I" Or ch = "O" Or ch =
namespace Slip3A "U") Then
{ MessageBox.Show(ch & " is " & str & " Vowel")
class Addition Else
{ MessageBox.Show(ch & " is " & str & "
static void Main(string[] args) Consonant")
{ End If
Addition a1 = newAddition(); End If
a1.add(); End Sub EndClass
Slip: 6 ListBox1.Items(i).ToString + Environment.NewLine
Public Class WebForm1 End If
Inherits System.Web.UI.Page Next
Protected Sub Button1_Click(ByVal sender As End If
Object, ByVal e As EventArgs) Handles End Sub
Button1.Click EndClass
Label1.Text = RadioButtonList1.SelectedValue
End Sub Slip: 9
EndClass Public Class WebForm1
Inherits System.Web.UI.Page
Slip: 7 Protected Sub Button1_Click(ByVal sender As
Public Class WebForm1 Object, ByVal e As EventArgs) Handles
Inherits System.Web.UI.Page Button1.Click
Protected Sub Button1_Click(ByVal sender As Dim num, rev As Integer
Object, ByVal e As EventArgs) Handles num = getnum.Text
Button1.Click rev = StrReverse(num)
Dim no, sum, i As Integer If num = rev Then
sum = 0 lbldisplay.Text = "Number is Palindrome"
no = TextBox1.Text Else
Try lbldisplay.Text = "Number is Not Palindrome"
For i = 1 To no- 1 End If
If no Mod i = 0 Then End Sub
sum = sum + i End Class
End If
Next Slip: 12
If no = sum Then <html xmlns="http://www.w3.org/1999/xhtml">
MsgBox("Number is Perfect number") <head runat="server">
Else <title></title>
Throw New ApplicationException("Number is not </head>
perfect number.") <body>
End If <form id="form1" runat="server">
Catch ex As Exception <div>
MsgBox(ex.Message) <div align="center">
End Try <asp:Button ID="Button1" runat="server"
End Sub BackColor="#33CC33" Height="53px"
End Class style="text-align: center; font-size: large"
Text="Click Me" Width="182px"
Slip: 8 onmouseover="this.style.backgroundColor='yello
Public Class WebForm1 w'"
Inherits System.Web.UI.Page onmouseout="this.style.backgroundColor='lightgr
Protected Sub Button1_Click(ByVal sender As een'"/>
Object, ByVal e As EventArgs) Handles </div>
Button1.Click </form>
If ListBox1.SelectedValue.Count = 0 Then </body>
For i = 0 To ListBox1.Items.Count- 1 </html>
TextBox1.Text = TextBox1.Text +
ListBox1.Items(i).ToString() + Slip: 13
Environment.NewLine Public Class Form1
Next Private Sub Timer1_Tick(ByVal sender As
Else System.Object, ByVal e As System.EventArgs)
For i = 0 To ListBox1.Items.Count- 1 Handles Timer1.Tick
If ListBox1.Items(i).Selected = True Then If PictureBox1.Visible = True Then
TextBox1.Text = TextBox1.Text + PictureBox1.Visible = False
ElseIf PictureBox1.Visible = False Then Private Sub BlueToolStripMenuItem_Click(sender
PictureBox1.Visible = True As Object, e As EventArgs) Handles
End If BlueToolStripMenuItem.Click
End Sub Me.BackColor = Color.Blue
Private Sub Button1_Click(ByVal sender As End Sub
System.Object, ByVal e As System.EventArgs) EndClass
Handles Button1.Click
Timer1.Enabled = True Slip: 16
End Sub Public Class WebForm1
Private Sub Button2_Click(ByVal sender As Inherits System.Web.UI.Page
System.Object, ByVal e As System.EventArgs) Protected Sub Button1_Click(ByVal sender As
Handles Button2.Click Object, ByVal e As EventArgs) Handles
Timer1.Enabled = False Button1.Click
End Sub If TextBox1.Text = "DYP" And TextBox2.Text =
EndClass "Pimpri" Then
Label3.Text = "You are Authorised User...!!!"
Slip: 14 Else
using System; Label3.Text = "You are Not Authorised User...!!!"
using System.Collections.Generic; End If
using System.Linq; End Sub
using System.Text; End Class
namespace Slip14A
{ Slip: 17
class Program using System;
{ using System.Collections.Generic;
static void Main(string[] args) using System.Linq;
{ using System.Text;
int sum = 0; namespace Slip17A
int[] arr = { 1, 5, 2, 6, 8, 9 }; {
int l = arr.Length; class Program
for (int i = 0; i < l ;i++ ) {
{ static void Main(string[] args)
sum=sum+arr[i]; {
} string str;
} Console.WriteLine("Enter the String:");
} str=Console.ReadLine();
} int l = str.Length;
for(int i=0;i<l;i++)
Slip: 15 {
Public Class Form1 if
Private Sub RedToolStripMenuItem_Click(sender (str[i]=='A'||str[i]=='a'||str[i]=='E'||str[i]=='e'||str
As Object, e As EventArgs) Handles [i]=='I'||str[i]=='i'||str[i]=='O'||str[i]=='o'||str[i]=
RedToolStripMenuItem.Click ='U'||str[i]=='u')
Me.BackColor = Color.Red Console.WriteLine(" "+ str[i]);
End Sub }
Private Sub Console.ReadLine();
GreenToolStripMenuItem_Click(sender As Object, }
e As EventArgs) Handles }
GreenToolStripMenuItem.Click }
Me.BackColor = Color.Green
End Sub
Slip: 18 For I = 0Toarr.Length- 1
Public Class Form1 If arr(I) = " " Then
Private Sub Button1_Click(ByVal sender As Count = Count + 1
System.Object, ByVal e As System.EventArgs) EndIf
Handles Button1.Click Next
ListBox1.Items.Clear() MsgBox(Count + 1 & " words")
Dimn, iAsInteger End Sub
n = InputBox("Enter number to create table") EndClass
For i = 1 To 10
ListBox1.Items.Add(i * n) Slip: 22
Next i using System;
End Sub using System.Collections.Generic;
EndClass using System.Linq;
using System.Text;
Slip: 19 namespace Slip22A
Public Class Form1 {
Private Sub Button1_Click(sender As Object, e As class Program
EventArgs) Handles Button1.Click {
Dimstr, rev As String public static void swap(int num1, int num2)
str = TextBox1.Text {
rev = StrReverse(str) int temp;
If (str = rev) Then temp = num1;
MessageBox.Show("String is Palindrome : " & str) num1 = num2;
Else num2 = temp;
MessageBox.Show("String is Not Palindrome : " & Console.WriteLine("after swapping first
str) no"+num1+" second no:"+ num2);
End If }
End Sub static void Main(string[] args)
EndClass {
Console.WriteLine("Enter two numbers:");
Slip: 20 int n1 = Convert.ToInt32(Console.ReadLine());
Public Class Form1 int n2 = Convert.ToInt32(Console.ReadLine());
Private Sub Button1_Click(ByVal sender As swap( n1, n2);
System.Object, ByVal e As System.EventArgs) Console.ReadLine();
Handles Button1.Click }
TreeView1.Nodes.Add("CCSCE") }
TreeView1.Nodes(0).Nodes.Add("BCA") }
TreeView1.Nodes(0).Nodes.Add("BCS")
TreeView1.Nodes.Add("Pharmacy") Slip: 23
TreeView1.Nodes(1).Nodes.Add("Dpharm") using System;
TreeView1.Nodes(1).Nodes.Add("BPharm") using System.Collections.Generic;
TreeView1.Nodes(1).Nodes.Add("pharm") using System.Linq;
End Sub using System.Text;
End Class namespace Slip23A
{
Slip: 21 class Fibo
Public Class Form1 {
Private Sub Button1_Click(sender As Object, e As public static int fibo(int no)
EventArgs) Handles Button1.Click {
Dimstr AsString int n1 = 0;
str = TextBox1.Text int n2 = 1;
DimI, Count As Integer for (int i = 0; i < no; i++)
Dimarr() As Char = str.ToCharArray {
int temp = n1; Slip: 25
n1 = n2; using System;
n2 = temp + n2; using System.Collections.Generic;
} using System.Linq;
return n1; using System.Text;
} namespace Slip25A
static void Main(string[] args) {
{ class Program
Console.WriteLine("Enter number for fibo {
series:"); static void Main(string[] args)
int n = Convert.ToInt32(Console.ReadLine()); {
Console.WriteLine("fibo series of" + n + "numbers int n,rem,sum=0;
is:"); Console.WriteLine("Enter the number:");
for (int i = 0; i < n; i++) n =Convert.ToInt32(Console.ReadLine());
{ while (n>0)
Console.WriteLine(fibo(i) + ""); {
} rem = n % 10;
Console.ReadLine(); sum = sum + rem;
} n = n/ 10;
} }
} Console.WriteLine("Sum of Digits=" + sum);
Console.ReadLine();
Slip: 24 }
using System; }
using System.Collections.Generic; }
using System.Linq;
using System.Text; Slip: 26
namespace Slip24 using System;
{ class Program
class Prime {
{ public static void Main()
public static bool checkprime(int no) {
{ int fact, num;
for (int i = 1; i < no; i++) Console.Write("Enter a number: ");
if (no % 2 == 0) num = Convert.ToInt32(Console.ReadLine());
return false; Program obj = new Program();
return true; fact = obj.factorial(num);
} Console.WriteLine("Factorial of {0} is {1}", num,
static void Main(string[] args) fact);
{ }
Console.WriteLine("Enter the Number:"); public int factorial(int num)
int n = Convert.ToInt32(Console.ReadLine()); {
if (checkprime(n)) if (num == 0)
Console.WriteLine(n + "is prime"); return 1;
Else else
Console.WriteLine(n + "is not prime"); return num * factorial(num- 1);
Console.ReadLine(); }
} }
}
}
Slip: 27 Console.WriteLine("Individual characters from the
using System; string: ");
using System.Collections.Generic; foreach (char c in characters)
using System.Linq; {
using System.Text; Console.Write(c + " ");
namespace Slip27A }
{ Console.ReadLine();
class Program }
{ }
static void Main(string[] args)
{ Slip: 30
string str; Public Class Form1
Console.WriteLine("Enter The String:"); Private Sub Button1_Click(ByVal sender As
str= Console.ReadLine(); System.Object, ByVal e As System.EventArgs)
int len = str.Length ; Handles Button1.Click
Console.WriteLine("Length of String=" + len); Dimbs, da, hra, ma, pf, gs, ts, ns, it As Integer
Console.ReadLine(); bs = TextBox2.Text
} da = bs * 15 / 100
} TextBox3.Text = da
} hra = bs * 10 / 100
TextBox4.Text = hra
Slip: 28 ma= 1000
namespace WinFormsApp23 pf = 1800
{ it = 500
public partial class Form1 : Form TextBox5.Text = ma
{ TextBox6.Text = pf
public Form1() TextBox7.Text = it
{ gs = bs + da + hra + ma'Gross Salary
InitializeComponent(); TextBox8.Text = gs
} TextBox9.Text = pf + it 'Total Deduction
private void button1_Click(object sender, ns = gs- pf-it 'Net Salary
EventArgs e) TextBox10.Text = ns
{ MsgBox("Employee Name : " & TextBox1.Text &
listBox1.Items.Add(textBox1.Text); Environment.NewLine & "Net Salary is : " &
} TextBox10.Text)
private void button2_Click(object sender, End Sub
EventArgs e) Private Sub Button2_Click(ByVal sender As
{ System.Object, ByVal e As System.EventArgs)
listBox2.Items.Clear(); Handles Button2.Click
for (int i = listBox1.Items.Count-1; i >= 0; i--) TextBox1.Text = ""
{ TextBox2.Text = ""
listBox2.Items.Add (listBox1.Items[i]); TextBox3.Text = ""
} TextBox4.Text = ""
} TextBox5.Text = ""
} TextBox6.Text = ""
} TextBox7.Text = ""
TextBox8.Text = ""
Slip: 29 TextBox9.Text = ""
using System; TextBox10.Text = ""
class Program { End Sub
static void Main(string[] args) { EndClass
string inputString = "Hello, world!";
char[] characters = inputString.ToCharArray();
❖ Java {
int f;Thread t;
slip1A public Slip2B()
import java.awt.*; {
public class Slip1A extends Frame implements t=new Thread(this);
Runnable t.start();
{ setSize(500,500);
int f,x; Thread t; setVisible(true);
public Slip1A() }
{ public void paint(Graphics g)
f=0; x=20; {
t=new Thread(this); int x[]={100,200,100};
t.start(); int y[]={150,200,250};
setSize(500,500); switch(f)
setVisible(true); {
} case 0: g.setColor(Color.red);
public void paint(Graphics g) g.fillPolygon(x,y,3);
{ case 1: g.drawLine(100,250,100,350);
g.drawString("abc",x,100); }
if(f==0) }
{ public void run()
x=x+50; {
if(x>getWidth()) while(true)
f=1; {
} repaint();
if(f==1) f=(f+1)%2;
{ try
x=x-50; {
if(x==0) Thread.sleep(200);
f=0; }
} catch(Exception e){}
} }
public void run() }
{ public static void main(String args[])
while(true) {
{ new Slip2B();
repaint(); }
try }
{
Thread.sleep(200); ❖ slip3AClient
}catch(Exception e){} import java.io.*;
} import java.net.*;
} class Slip3AClient
public static void main(String args[]) {
{ public static void main(String args[])throws
new Slip1A(); Exception
} {
} Socket s=new Socket(1616);
DataInputStream dis=new
❖ slip2B DataInputStream(System.in);
import java.awt.*; System.out.println("enter the
public class Slip2B extends Frame implements number:");
Runnable
int n=Integer.parseInt(dis.readLine()); {
Class for Name(“com.Mysql.jdbc.driver”);
DataOutputStream dos=new Connection con.Drivermanager.get connection
DataOutputStream(s.getOutputStream()); (“jdbc:mysql://localhost:3306/bca2025”,”root”,”
dos.writeBytes(n+"\n"); “);
Statement stmt=con.create statement();
DataInputStream din=new Stmt.executeupdate(“delete*form statement
DataInputStream(s.getInputStream()); where name like ‘s’ “);
System.out.println(din.readLine()); System.out.println(“file deleted successfully”);
s.close(); Con.close();
} }
} }

❖ Slip3AServer ❖ Slip5a.jsp
import java.io.*; <%@page contentType="text/html"%>
import java.net.*; <%!int n,f,l;%>
class Slip3AServer <%
{ int
public static void main(String args[])throws n=Integer.parseInt(request.getParameter("t1"));
Exception l=n%10;
{ while(n>0)
ServerSocket ss=new {
ServerSocket(1616); f=n%10;
Socket s=ss.accept(); n=n/10;
DataInputStream dis =new }
DataInputStream(s.getInputStream()); out.println("the sum of first and last digit is");
%>
int n1=Integer.parseInt(dis.readLine()); <font color="red" size="18"><%=f+l%>
int cnt=0; </font>
for(int i=2;i<n1;i++)
{ 5a.html
if(n1%i==0) <html>
{ <body>
cnt++; <form
break; method="post"action="http://localhost:11000/jsp_fol
} der_name/Slip5A.jsp">
} Enter No<input type="text" name="t1"><br><br>
DataOutputStream dos =new <input type="submit" value="sum">
DataOutputStream(s.getOutputStream()); </form>
if(cnt==0) </body>
dos.writeBytes(n1+"is </html>
prime.");
else Slip6A
dos.writeBytes(n1+"is not import java.awt.*;
prime."); import javax.swing.*;
} public class Slip6A extends Canvas implements
} Runnable
❖ Slip4A {
import java.sql.*; int f;
class_Slip4A Thread t1;
{ public Slip6A()
Public static void main(String args[j]throws {
Exception t1=new Thread(this);
t1.start(); <form method="POST"
} action="http://localhost:11000/jsp_folder_name/Slip7
public void paint(Graphics g) A.jsp">
{ enter e-mail id<input type="text"name="t1">
Toolkit t=Toolkit.getDefaultToolkit(); <input type="submit"value="check">
Image i1=t.getImage("car.jpg"); </form>
switch(f) </body>
{ </html>
case 0:
g.drawImage(i1,50,50,this); Slip8B
break; import java.sql.*;
case 1: Class Slip8A
g.clearRect(50,50,290,290); {
break; Public static void main(String args[j]throws Exception
} {
} Class for name(“com.mysql.jdbc.Driver”);
public void run() Connection con=Drivermanager.getconnection
{ (“jdbc.mysql:/localhost:3306/bca2025”;”root”,””);
while(true) Statement stmt=con.createstatement();
{ Resultstate rs=stmt.executequery(“select ename from
repaint(); emp where ename like ‘A%’”);
f=(f+1)%2; System.out.println(rs.next());
try While(rs.next())
{ {S
Thread.sleep(20); System.out.println(rs.getstring(1));
} }
catch(Exception e){} Con.close();
} }
}
} Slip9A
public static void main(String args[]) import java.io.*;
{ import java.sql.*;
JFrame jf=new JFrame(); class Slip9A
Slip6A s1=new Slip6A(); {
jf.add(s1); public static void main(String args[])throws
jf.setSize(300,300); Exception
jf.setVisible(true); {
} Connection con;
} PreparedStatement pstmt;
int no,s;
7A.jsp Class.forName("com.mysql.jdbc.Driver");
<%@page contentType="text/html"%>
<%String str=request.getParameter("t1"); con=DriverManager.getConnection("jdbc:mysql://local
if(str.contains("@")&& str.contains(".")) host:3306/tybba","root","");
out.println("Email valid"); pstmt=con.preparStatement("create table
else employee2(eno int, ename varchar(20),sal float");
out.println("Email Invalid"); pstmt.execute();
%> System.out.println("table created");
pstmt=con.preparStatement("insert into
7a.html employee2 values(?,?,?");
<html> DataInputStream dis = new
<body> DataInputStream(System.in);
System.out.println("enter eno,ename and sal");
no=Integer.parseInt(dis.readLine()); <form method="POST"
nm=dis.readLine(); action="http://localhost:11000/jsp_folder_name/Slip1
pstmt.setInt(1,no); 3B.jsp">
pstmt.setInt(2,nm); enter college id<input
pstmt.setfloat(3,s); type="text"name="t1"><br><br>
System.out.println("record inserted"); enter college name<input
con.close(); type="text"name="t2"><br><br>
} enter address<input
} type="text"name="t3"><br><br>
<input type="submit"value="display">
Slip12A </form>
</body>
import java.sql.*; </html>
class Slip12A
{ 14BServer
public static void main(String args[])throws Exception
{ import java.net.*;
import java.io.*;
Class.forName("com.mysql.jdbc.Driver"); class Slip14BServer
Connection con = {
DriverManager.getConnection("jdbc:mysql://localhost public static void main(String args[])throws Exception
:3306/tybba","root",""); {
Statement stmt = ServerSocket ss=new ServerSocket(1313);
con.createStatement(); Socket s=ss.accept();
ResultSet rs = DataInputStream dis=new
stmt.executeQuery("select * from employee2"); DataInputStream(s.getInputStream());
int cnt=0; String dir=dis.readLine();
while(rs.next()) String ext=dis.readLine();
{ File f1=new File(dir+":");
cnt++; String s1[]=f1.list();
} if(s1==null)
System.out.println("no of records in System.out.println("dir does not
employee2 table"+cnt); exist");
con.close(); else
} {
} for(int i=0;i<s1.length;i++)
{
Slip13b.jsp if(s1[i].endsWith(ext))
<%@page contentType="text/html"%> System.out.println(s1[i]);
<font color="black">
<table border="1"> }
<tr><th>id</th><th>name</th><th>address</th></tr }
> }
<tr><td><%= request.getParameter("t1")%></td> }
<td><%= request.getParameter("t2")%></td>
<td><%= request.getParameter("t3")%></td> 15A
</tr> class Alpha extends Thread
</table> {
</font> public void run()
{
13B.html try
<html> {
<body> Thread.sleep(2000);
} int l;
catch(Exception e){} DataInputStream dis=new
for(int i=97;i<=122;i++) DataInputStream(System.in);
System.out.println((char)i); System.out.println("enter the string");
str=dis.readLine();
} l=str.length();
} for(int i=0;i<l;i++)
class Slip15A {
{ char ch=str.charAt(i);
public static void main(String arg[])
{ if(ch=='a'||ch=='A'||ch=='e'||ch=='E'||ch=='i'||ch=='I
Alpha a1=new Alpha(); '||ch=='o'||ch=='O'||ch=='u'||ch=='U')
a1.start(); {
} Thread.sleep(3000);
} System.out.println(ch);
}
}
16a.jsp }
}
<%@page contentType="text/html"%>
<% 18A
String unm=request.getParameter("t1");
import java.io.*;
String pw=request.getParameter("t2"); class Fact extends Thread
if(unm.equals(pw)) {
response.sendRedirect("login.html"); public void run()
else {
response.sendRedirect("error.html"); try
%> {
DataInputStream dis =new
16a.html DataInputStream(System.in);
<html> System.out.println("enter the no");
<body> int n=Integer.parseInt(dis.readLine());
<form method="POST" int f=1;
action="http://localhost:11000/jsp_folder_name/Slip1 for(int i=1;i<=n;i++)
6A.jsp"> {
enter username<input type="text" f=f*i;
name="t1"><br><br> sleep(2000);
enter password<input type="text"
name="t2"><br><br> }
<input type="submit"value="login"> System.out.println(" factorial is"+f);
</form> }
</body>
</html> catch(Exception e){}

17A }
}
import java.io.*; class Slip18A
class Slip17A
{ {
public static void main(String args[])throws Exception public static void main(String args[])
{ {
String str; Fact f1=new Fact();
f1.start(); System.out.println("record deleted");
con.close();
} }
} }

21A

19a.jsp class Slip21A


<%@page contentType="text/html" {
import="java.util.*"%> public static void main(String args[])
<% Date d1=new Date(); {
int t=d1.getHours(); Thread t1=Thread.currentThread();
String nm=request.getParameter("t1"); System.out.println(" Display name of current
if(t<12) "+t1.getName());
out.println("Good Morning" +nm); System.out.println("the priority of
else if(t>=12 && t<=16) thread"+t1.getPriority());
out.println("Good Afternoon"+nm); }
else if(t>16 && t<=19) }
out.println("Good Evenning"+nm);
else 21B
out.println("good night"+nm);
%>
import java.io.*;
19a.html import javax.servlet.*;
<html> import javax.servlet.http.*;
<body> public class Slip21B extends HttpServlet
<form method="POST" {
action="http://localhost:11000/jsp_folder_name/Slip1 public void doGet(HttpServletRequest
9A.jsp"> req,HttpServletResponse res)throws
enter username<input ServletException,IOException
type="text"name="t1"><br><br> {
<input type="submit"value="submit"> res.setContentType("text/html");
</form> PrintWriter out=res.getWriter();
</body>
</html> String no=req.getParameter("t1");
String nm=req.getParameter("t2");
20A String Cl=req.getParameter("t3");
int tm= Integer.parseInt(req.getParameter("t4"));
import java.sql.*; float per=tm/5;
class Slip20A String gd;
{ if (per>=70)
public static void main(String args[])throws Exception gd="Distinction";
{ else if (per>=60 && per<70)
int id; gd="1st Class";
Connection con; else if (per>=55 && per<60)
Statement stmt; gd="Higher Second Class";
Class.forName("com.mysql.jdbc.Driver"); else if(per>=50 && per<55)
con=DriverManager.getConnection("jdbc:mysql://local gd="Second Class";
host:3306/tybba","root",""); else if(per>=40 && per<50)
stmt=con.createStatement(); gd="pass";
id=Integer.parseInt(args[0]); else
stmt.executeUpdate("delete from employee2 where gd="Fail";
eno="+id+"");
out.println("<table><tr><th>Seat No</th> <th>Stud import java.awt.*;
Name</th> <th> Class</th><th> Total Marks</th> import javax.swing.*;
<th> Percentage</th><th> Grade</th></tr>"); import javax.swing.table.*;
import java.util.*;
public class Slip23A extends JFrame
out.println("<tr> {
<td>"+no+"</td><td>"+nm+"</td><td>"+Cl+"</td><td Connection con;
>"+tm+"</td><td>"+per+"</td><td>"+gd+"</td></tr> Statement stmt;
</table>"); ResultSet rs;
out.close(); JTable jt;
} DefaultTableModel dtm;
} public Slip23A()
{
22AClient setLayout(null);
JFrame jf=new JFrame();
import java.net.*; jf.setSize(500,500);
import java.io.*; jf.setVisible(true);
class Slip22AClient
{ dtm=new DefaultTableModel();
public static void main(String args[])throws Exception dtm.addColumn("cid");
{ dtm.addColumn("cname");
Socket s=new Socket("localhost",5050); dtm.addColumn("addr");
DataInputStream dis=new dtm.addColumn("year");
DataInputStream(s.getInputStream());
System.out.println("Serever date and time jt=new JTable(dtm);
is"+dis.readLine()); JScrollPane js= new JScrollPane(jt);
s.close();
}
} jf.add(js,BorderLayout.CENTER);

22AServer setDefaultCloseOperation(JFrame.EXIT_ON_CL
OSE);
import java.net.*; try
import java.io.*; {
import java.util.*; Class.forName("com.mysql.jdbc.Driver");
class Slip22AServer System.out.println("ss");
{
public static void main(String args[])throws Exception con=DriverManager.getConnection("jdbc:mys
{ ql://localhost:3306/tybba","root","");
ServerSocket ss=new ServerSocket(5050); stmt=con.createStatement();
Socket s=ss.accept(); rs=stmt.executeQuery("select
DataInputStream dis=new * from college1");
DataInputStream(s.getInputStream()); while(rs.next())
Date d1=new Date(); {
DataOutputStream dos=new Vector v=new
DataOutputStream(s.getOutputStream()); Vector();
dos.writeBytes(d1+"\n"); v.add(rs.getInt(1));
} v.add(rs.getString(2));
} v.add(rs.getString(3));
v.add(rs.getInt(4));
23A dtm.addRow(v);
}
import java.sql.*; con.close();
}catch(Exception e){} <input type="submit"value="Display">
} </form>
public static void main(String args[]) </body>
{ </html>
new Slip23A();
} 25AClient
}
import java.util.*;
24a.jsp import java.io.*;
<% import java.net.*;
String str=request.getParameter("t1"); public class Slip25AClient
int l=str.length(); {
%> public static void main(String args[])throws
<font color="red"> Exception
<% {
for(int i=0;i<l;i++) Socket s=new Socket("localhost",1111);
{ DataInputStream dis=new
char ch=str.charAt(i); DataInputStream(System.in);
switch(ch) System.out.println("enter the no");
{ DataOutputStream dos=new
case '0': out.println("Zero"); DataOutputStream(s.getOutputStream());
break; dos.writeUTF("Connected \n");
case '1': out.println("One"); int n=Integer.parseInt(dis.readLine());
break; dos.writeUTF(String.valueOf(n));
case '2': out.println("Two"); DataInputStream din=new
break; DataInputStream(s.getInputStream());
case '3': out.println("Three"); System.out.println(new String(din.readUTF()));
break;
case '4': out.println("Four"); }
break; }
case '5': out.println("Five");
break; 25AServer
case '6': out.println("Six"); import java.util.*;
break; import java.io.*;
case '7': out.println("Seven"); import java.net.*;
break; public class Slip25AServer
case '8': out.println("Eight"); {
break; public static void main(String args[])throws
case '9': out.println("Nine"); Exception
break; {
ServerSocket ss=new ServerSocket(1111);
} Socket s=ss.accept();
} DataInputStream dis=new
%> DataInputStream(s.getInputStream());
</font> dis.readUTF();
int n=Integer.parseInt(dis.readUTF());
24A.html
<html> DataOutputStream dos=new
<body> DataOutputStream(s.getOutputStream());
<form method="POST" for(int i=1;i<=n;i++)
action="http://localhost:11000/jsp_folder_name/Slip2 {
4A.jsp"> if(n%i==0)
enter number<input type="text"name="t1"> {
dos.writeUTF(i+"\n"); out.println("You Selected "+hb+"hobby");
System.out.println(i); }
} else
} {
s.close(); String hb=c[0].getValue();
} out.println("You Selected "+hb+"hobby");
} }
}
26A }

import java.sql.*; 27a.jsp


class Slip26A <%@page contentType="text/html"%>
{ <table border='1'>
public static void main(String args[])throws Exception <Tr><th>Tid</th><th>Tnm</th><th>Desg</th><th>Su
{ b</th><th>Qualification</th><th></tr>
<tr><td><%=request.getParameter("t1")%></td>
Class.forName("com.mysql.jdbc.Driver"); <td><%=request.getParameter("t2")%></td>
Connection con = <td><%=request.getParameter("t3")%></td>
DriverManager.getConnection("jdbc:mysql://localhost <td><%=request.getParameter("t4")%></td>
:3306/fff","root",""); <td><%=request.getParameter("t5")%></td>
Statement stmt = </tr></table>
con.createStatement();
ResultSet rs = 27A.html
stmt.executeQuery("select cname from collage"); <html>
while(rs.next()) <body>
{ <form method="Post"
action="http://localhost:11000/jsp_folder_name/Slip2
System.out.println(rs.getString(1)); 7A.jsp">
} Teacher id<input type="text" name="t1"><br><br>
Teacher Name<input type="text"
con.close(); name="t2"><br><br>
} Designation<input type="text" name="t3"><br><br>
} Subject<input type="text" name="t4"><br><br>
Qualification<input type="text" name="t5"><br><br>
26B <input type="submit"value="Display">
</form>
import java.io.*; </body>
import javax.servlet.*; </html>
import javax.servlet.http.*;
public class Slip26B extends HttpServlet 29B
{
public void doGet(HttpServletRequest import java.io.*;
req,HttpServletResponse res)throws import javax.servlet.*;
ServletException,IOException import javax.servlet.http.*;
{ public class Slip29B extends HttpServlet
res.setContentType("text/html"); {
PrintWriter out=res.getWriter(); public void doGet(HttpServletRequest
Cookie c[]=req.getCookies(); req,HttpServletResponse res)throws
if(c==null) ServletException,IOException
{ {
String hb=req.getParameter("r1"); res.setContentType("text/html");
Cookie c1=new Cookie("hobby",hb); PrintWriter out=res.getWriter();
res.addCookie(c1); HttpSession hs=req.getSession();
out.println(hs.getId());
out.println("Before change time is <br>");
out.println(hs.getMaxInactiveInterval());
hs.setMaxInactiveInterval(2*60);
out.println("After change time is <br>");
out.println(hs.getMaxInactiveInterval());
}
}

30A.jsp
<%@page contentType="text/html"%>
<%
String str=request.getParameter("t1");
StringBuffer sb=new StringBuffer(str);
out.println("reverse string is" +sb.reverse());
%>
30A.html
<html>
<body>
<form method="POST"
action="http://localhost:11000/jsp_folder_name/Slip3
0A.jsp">
enter any string<input
type="text"name="t1"><br><br>
<input type="submit"value="reverse">
</form>
</body>
</html>

You might also like