IT7412
IT7412
ANNA UNIVERSITY
DEPARTMENT OF INFORMATION TECHNOLOGY
To educate students with conceptual knowledge and technical skills in the field of
Information Technology with moral and ethical values to achieve excellence in an academic,
industry and research centric environment.
1. To inculcate in students a firm foundation in theory and practice of IT skills coupled with
the thought process for disruptive innovation and research methodologies, to keep pace with
emerging technologies.
2. To provide a conducive environment for all academic, administrative, and interdisciplinary
research activities using state-of-the-art technologies.
3. To stimulate the growth of graduates and doctorates, who will enter the workforce
as productive IT engineers, researchers, and entrepreneurs with necessary soft skills, and
continue higher professional education with competence in the global market.
4. To enable seamless collaboration with the IT industry and Government for consultancy and
sponsored research.
5. To cater to cross-cultural, multinational, and demographic diversity of students.
6. To educate the students on the social, ethical, and moral values needed to make significant
contributions to society.
After completion of the B.Tech. (IT) course, students will be able to:
PSO1: To apply programming principles and practices for the design of software solutions in
an internet-enabled world of business and social activities.
PSO2: To identify the resources to build and manage the IT infrastructure using the current
technologies in order to solve real world problems with an understanding of the tradeoffs
involved in the design choices.
PSO3: To plan, design and execute projects for the development of intelligent systems with a
focus on the future
Exercises
1. Creating simple applications using JAVA by exploring all the object oriented
programming
concepts such as inheritance, polymorphism, interfaces and packages.
2. Creating GUI based application using JAVA Swings
3. Developing concurrent and generic programming using Threads
4. Creation of simple websites using HTML 5 Tags
5. Creation of web forms and validating it through javascripts
6. Creation of XML file and validating with DTD and XML schema
7. Working with DOM and SAX parsers
8. Creation of AJAX based application
9. Developing JSON application
10. Creation of dynamic HTML based web applications
11. Creation of servlet based web application with JDBC
12. Developing JSP application
13. Creating simple applications using python
14. Simple database and web application using python
TOTAL: 60 PERIODS
OUTCOMES:
On Completion of the course, the students should be able to:
Create simple web applications
Implement server side and client side programming develop web applications with
various web technology concepts.
Program Outcomes(POs)
CO PSO1 PSO2 PSO3
1 2 3 4 5 6 7 8 9 10 11 12
Create simple 1 2 3 1 1 1 0 0 0 0 1 1 2 2 2
web
applications
Write programs 1 2 3 2 2 0 0 0 0 0 0 1 2 2 2
on streaming,
multithreading
and generic
Develop web 1 2 2 3 3 2 2 0 0 0 0 1 2 2 2
based
applications
using jdbc
Implement 1 2 2 3 3 2 2 0 2 1 3 1 2 2 2
server side
programming
using servlet
and jsp
Develop simple 1 2 2 3 3 3 3 1 2 1 3 1 2 2 2
web application
using python
2. Java IO Statements
3. Java Constructors
4. Java Inheritance
6. Java Arrays
7. Java Collections
9. Java Threading
SOURCE CODE:
package class_and_objects;
import java.util.*;
public class Fact_num {
II PRIME NUMBER
ALGORITHM
1: Start
2: Read number n
3: Set f=0
4: For i=2 to n-1
5: If n mod 1=0 then
6: Set f=1 and break
7: Loop
8: If f=0 then
print 'The given number is prime'
else
print 'The given number is not prime'
9: Stop
ALGORITHM
Input: num
1: Initialize rev_num = 0
2: Loop while num > 0
Multiply rev_num by 10 and add remainder of num
divide by 10 to rev_num
rev_num = rev_num*10 + num%10;
Divide num by 10
3: Return rev_num
SOURCE CODE
package class_and_objects;
import java.util.*;
public class Reverse_of_num {
while(n != 0)
OUTPUT
IV ARMSTRONG NUMBER
ALGORITHM
1:read number
2:set sum=0 and duplicate=number
3:while number > 0
4:reminder=number%10
5:sum=sum+(reminder*reminder*reminder)
SOURCE CODE
package class_and_objects;
import java.util.*;
public class Armstrong_no {
count = n;
while (count != 0) {
digits++;
count = count/10;
}
count = n;
while (count != 0) {
remainder = count%10;
sum = sum + power(remainder, digits);
count = count/10;
}
if (n == sum)
System.out.println(n + " is an Armstrong number.");
else
System.out.println(n + " isn't an Armstrong number.");
}
return p;
OUTPUT
V SUM OF DIGITS
ALGORITHM
1. Input a Number
2. Initialize Sum to zero
3. While Number is not zero
Get Remainder by Number Mod 10
Add Remainder to Sum
Divide Number by 10
4. Print sum
VI PALINDROME OF A NUMBER
ALGORITHM
1:Start
2:get a number(x)
3:set p=0 and temp=x
4:divide x by 10, store reminder (x%10) in r
5:set x=x/10
6:set p= p + r
7:set p=p*10
8:repeat from step 4 till x is equal to 0
9: set p = p /10
10: check if p is equal to temp
11: if so, print palindrome
12: else print not a palindrome
13:Stop
RESULT
AIM
To create java programs using various methods of input arguments.
ALGORITHM
SOURCE CODE
package class_and_objects;
while(m > 0)
{
n = m % 10;
sum = sum + n;
m = m / 10;
}
System.out.println("Sum of Digits:"+sum);
import java.io.*;
count = n;
while (count != 0) {
digits++;
count = count/10;
}
count = n;
while (count != 0) {
remainder = count%10;
sum = sum + power(remainder, digits);
count = count/10;
}
if (n == sum)
System.out.println(n + " is an Armstrong number.");
else
System.out.println(n + " isn't an Armstrong number.");
}
return p;}}
ALGORITHM
1: Input a number using command line argument
2. Initialize i and fact to 1.
3. Repeat step 4 and step 5 while i is not equal to n.
4. fact <- fact * i
5. i <- i +1
6. Return fact
SOURCE CODE
package class_and_objects;
OUTPUT
RESULT
Thus java IO programs are implemented and executed successfully.
AIM
To implement the types of constructors using java programs.
I. DEFAULT CONSTRUCTORS
ALGORITHM
1.Start the program
2. Use the default constructor in the program
3. End the program.
SOURCE CODE
package class_and_objects;
class Run{
Run(){
System.out.println("Cancer is a most dreadful disease");
}
void play(){
String k="Chemotherapy";
System.out.println("It can be cured by following "+k+" at regular interval
of time");
}
}
II COPY CONSTRUCTORS
ALGORITHM
1.Start the program.
2.Use the copy constructor in the program.
3.End the program.
SOURCE CODE
package class_and_objects;
class Patient{
int id;
String name;
Patient(int i ,String n){
id=i;
name=n;
}
Patient(Patient s){
id = s.id;
name =s.name;
}
void display(){System.out.println(id+" "+name);
}
}
OUTPUT
}
OUTPUT:
RESULT
Thus the types of constructors are implemented and executed successfully.
AIM
To work with different types of inheritances using java.
I SINGLE INHERITANCE
ALGORITHM
1. Start the program.
2. Implement the java single inheritance in the program.
3. End the program.
SOURCE CODE
package class_and_objects;
import java.util.*;
//single inheritance
abstract class Species{
String[] array = new String[20];
int n;
void get_animal_species()
{
Scanner in = new Scanner(System.in);
System.out.println("Enter the no of species");
n=in.nextInt();
System.out.println("Enter the animal species");
for(int i=0;i<n;i++)
array[i]=in.next();
}
abstract void print_animals();
}
public class Humans extends Species {
String conserve="Zoological parks";
void print_animals() {
for(int i=0;i<n;i++)
System.out.println("The "+array[i]+" is the name of the species");
}
void print_results() {
System.out.println("The "+conserve+" is responsible is
maintaining for this species");
}
OUTPUT
II MULTIPLE INHERITANCES
ALGORITHM
1.Start the program.
2.Implement the multiple inheritance in the program.
3.End the program.
SOURCE CODE:
package class_and_objects;
//multiple inheritance
interface Car
{
int speed=60;
public void distanceTravelled();
}
interface Bus
{
int distance=100;
public void speed();
OUTPUT
Sem1()
{
m11=95;
m12=93;
m13=88;
m14=90;
avg1=(m11+m12+m13+m14)/4;
}
}
class Sem2 extends Sem1
{
int m21,m22,m23,m24,avg2;
Sem2()
{
m21=89;
m22=98;
m23=97;
m24=79;
avg2=(m21+m22+m23+m24)/4;
}
}
class Sem3 extends Sem2
{
int m31,m32,m33,m34,avg3;
Sem3()
{
m31=87;
m32=78;
m33=88;
avg3=(m31+m32+m33+m34)/4;
int m41,m42,m43,m44,avg4;
Sem4()
{
m41=79;
m42=90;
m43=77;
m44=96;avg4=(m41+m42+m43+m44)/4;
}
int totatavg()
{
return (avg1+avg2+avg3+avg4)/4;
}
}
class Semester
{
public static void main(String args[])
{
IV HEIRARCHIAL INHERITANCE
ALGORITHM
1.Start the program.
2.Use the hierarchical inheritance in the program.
3.End the program.
SOURCE CODE:
package class_and_objects;
//hierarchial Inheritance
class Human
{
public void behaviour()
{
System.out.println("Man is a social being");
}
}
class Employee extends Human
{
public void role()
{
System.out.println("Employee is one role of Human in day to day life");
}
}
class Student extends Human
{
public void stage()
{
System.out.println("Student life is a part of life in every human's life");
}
class Person
{
public static void main(String args[])
{
Employee obj1 = new Employee();
Student obj2 = new Student();
//All classes can access the method of class A
obj1.behaviour();
obj2.stage();
obj1.role();
}
}
OUTPUT
V HYBRID INHERITANCE
ALGORITHM
1.Start the program.
2. Use the hybrid inheritance in the program.
3. End the program.
class Manoj
{
String name="Manoj";
void printX()
{
System.out.println(name);
}
void print_SBI()
{
print_SS();
System.out.println(name+ "'s favourite player is "+sp);
}
obj.printX();
obj.print_play();
obj.print_SBI();
f.func();
}
}
OUTPUT
RESULT
Thus the types of inheritances are implemented and executed using java
programs.
interface Programmer{
void program();
void life();
void office();
}
interface Family{
void routine();
void happiness();
}
}
OUTPUT
class Company
{
OUTPUT
OUTPUT
RESULT
Thus, interfaces and polymorphism has been implemented using java
programs
if(my_array1.length == my_array2.length)
{
for (int i = 0; i < my_array1.length; i++)
{
if(my_array1[i] != my_array2[i])
{
equalOrNot = false;}}}
else
{
equalOrNot = false;
}
if (equalOrNot)
{
System.out.println("Two arrays are equal.");
}
else
OUTPUT
SOURCE CODE
System.out.println("Original Array :
"+Arrays.toString(my_array));
}
OUTPUT
int Index_position = 2;
int newValue = 5;
if(my_array[i] == my_array[j])
{
my_array[j] = my_array[no_unique_elements-1];
no_unique_elements--;
j--;
}
}
}
System.out.println();
System.out.println();
System.out.println("---------------------------");
}
V JAGGED ARRAY
ALGORITHM
1.Start the program.
2.Implement the jagged array in the java program.
3.End the program.
SOURCE CODE
package class_and_objects;
public class JaggedArrays
{
// 1st row
student[0][0] = "Karthi";
student[0][1] = "ROLL no:14";
student[0][2] = "M1:21";
student[0][3] = "M2:22";
// 2nd row
student[1][0] = "ROLL no:26";
// 3rd row
System.out.println("Student Form");
OUTPUT
RESULT
Thus arrays are implemented using java programs.
}
}
}
OUTPUT
II HASHSET
ALGORITHM
1. Start the program.
2. Implement hashset using generics.
3.End the program.
}
}
OUTPUT
IV LINKED HASHMAP
ALGORITHM
1. Start the program.
2. Implement the linked hashmap using generics.
3. End the program.
int hashcode = 0;
hashcode = price*20;
hashcode += item.hashCode();
return hashcode;
}
public boolean equals(Object obj)
{
if (obj instanceof Price_1) {
Price_1 pp = (Price_1) obj;
return (pp.item.equals(this.item) && pp.price == this.price);
} else {
return false;
}
}
public String getItem() {
return item;
}
public void setItem(String item) {
this.item = item;
}
public int getPrice() {
OUTPUT
V HASHTABLE
ALGORITHM
1.Start the program.
2.Implement the hashtable using generics.
3.End the program.
@Override
public int hashCode() {
return this.getId();
}
@Override
}
}
public class MyHashtableUserKeys
{
VI LINKED HASHSET
ALGORITHM
1. Start the program.
2. Implement the linked hashset using generics.
3. End the program.
SOURCE CODE:
package class_and_objects;
import java.util.LinkedHashSet;
class Amount{
}
}
VII TREEMAP
ALGORITHM
1. Start the program.
2. Implement the treemap using generics.
3. End the program.
SOURCE CODE
package class_and_objects;
import java.util.Map.Entry;
import java.util.*;
Iterator ii=vct.iterator();
while(ii.hasNext()) {
Object key=ii.next();
System.out.print(key+" \t\n");
}
List<String> list = vct.subList(2, 4);
System.out.println("Sub List: "+list);
IX TREESET
ALGORITHM
1.Start the program.
2.Implement the treeset using generics.
3.End the program.
SOURCE CODE
package class_and_objects;
import java.util.Comparator;
import java.util.Iterator;
import java.util.TreeSet;
class MySalCompr1 implements Comparator<Empl2>{
@Override
public int compare(Empl2 e1, Empl2 e2) {
if(e1.getSalary() > e2.getSalary()){
return 1;
} else {
return -1;
}
@Override
public int compare(Empl e1, Empl e2) {
if(e1.getSalary() < e2.getSalary()){
return 1;
} else {
return -1;
}
}
}
class Empl{
OUTPUT
RESULT
Thus the types of collections are implemented using java programs.
AIM
To implement swing using java.
I CALCULATOR
ALGORITHM
1. Start the program.
2.Use jlabel, jbutton, jtextfield in the program.
3.End the program.
SOURCE CODE
package class_and_objects;
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
// create a textfield
static JTextField l;
// default constrcutor
public Swing1()
{
s0 = s1 = s2 = "";
}
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 888, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 550, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()
);
}
catch (Exception e) {
System.err.println(e.getMessage());
}
// create a textfield
l = new JTextField(16);
// equals button
beq1 = new JButton("=");
// create . button
be = new JButton(".");
// create a panel
JPanel p = new JPanel();
f.setSize(200, 220);
f.show();
}
public void actionPerformed(ActionEvent e)
{
String s = e.getActionCommand();
double te;
// convert it to string
s0 = Double.toString(te);
s1 = s2 = "";
}
else {
// if there was no operand
if (s1.equals("") || s2.equals(""))
s1 = s;
// convert it to string
s0 = Double.toString(te);
II CHARACTER FUNCTIONS
ALGORITHM
1. Start the program.
2. Use jlabel, jbutton, jtextfield in the program.
3. End the program.
SOURCE CODE
public class Srevchar extends javax.swing.JFrame {
/**
* Creates new form Srevchar
*/
public Srevchar() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
always
* regenerated by the Form Editor.
jButton2.setText("space character");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setText("Vowels/consonants");
jButton3.addActionListener(new java.awt.event.ActionListener() {
jLabel1.setText("Enter");
jTextField2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField2ActionPerformed(evt);
}
});
jLabel2.setText("Result");
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.T
RAILING)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton1)
.addGap(44, 44, 44)
.addComponent(jButton2))
.addComponent(jTextField1))
.addComponent(jTextField2,
javax.swing.GroupLayout.PREFERRED_SIZE, 218,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(20, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jButton3)
.addGap(74, 74, 74))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(37, 37, 37)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jLabel1)
.addComponent(jTextField1,
javax.swing.GroupLayout.PREFERRED_SIZE,
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addGap(18, 18, 18)
.addComponent(jButton3)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jTextField2,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addContainerGap(37, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code
(optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the
default look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Srevchar.class.getName()).log(java.util.log
ging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Srevchar.class.getName()).log(java.util.log
ging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Srevchar.class.getName()).log(java.util.log
ging.Level.SEVERE, null, ex);
}
//</editor-fold>
OUTPUT:
SOURCE CODE
public class aaa extends javax.swing.JFrame {
public aaa() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jTextArea2.setColumns(20);
jTextArea2.setRows(5);
jScrollPane2.setViewportView(jTextArea2);
jButton1.setText("ARMSTRONG");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("PALINDROME");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setText("SUM OF DIGITS");
jButton3.addActionListener(new java.awt.event.ActionListener() {
jButton4.setText("REVERSE");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jButton5.setText("PRIME");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addComponent(jButton5)
.addComponent(jButton2)
.addComponent(jButton1)
.addComponent(jButton3)
.addComponent(jButton4)))
.addGroup(layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(jScrollPane2,
javax.swing.GroupLayout.PREFERRED_SIZE, 507,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(316, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(28, 28, 28)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code
(optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the
default look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
java.util.logging.Logger.getLogger(aaa.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(aaa.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(aaa.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(aaa.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
}
//</editor-fold>
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.T
RAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING) .addComponent(jLabel1)
.addComponent(jLabel2))
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING) .addComponent(jLabel3,
javax.swing.GroupLayout.PREFERRED_SIZE, 161,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton1)
.addGap(18, 18, 18)
.addComponent(jButton2))
.addComponent(jPasswordField1)
.addComponent(jTextField1))))
.addComponent(jProgressBar1,
javax.swing.GroupLayout.PREFERRED_SIZE, 179,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
31, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jPasswordField1,
javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELAT
ED)
.addComponent(jProgressBar1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(13, 13, 13)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE) .addComponent(jButton1)
.addComponent(jButton2))
.addGap(18, 18, 18)
.addComponent(jLabel3)
.addContainerGap(67, Short.MAX_VALUE))
); pack();
jProgressBar1.setValue(100);
String uname="admin";String upass="admin123";
String name=jTextField1.getText();
String pass=jPasswordField1.getText();
if(name.equals(uname)&&pass.equals(upass))
jLabel3.setText("Login is Successfull!");
else
jLabel3.setText("Login is not Successfull! !");
} private void jButton2ActionPerformed(java.awt.event.ActionEvent
evt) {
jProgressBar1.setValue(0);
jPasswordField1.setText("");
jTextField1.setText("");
jLabel3.setText("");
} try {
java.util.logging.Logger.getLogger(Slogin.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Slogin.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Slogin.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} //</editor-fold>/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Slogin().setVisible(true);
}}); } // Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPasswordField jPasswordField1;
private javax.swing.JProgressBar jProgressBar1;
private javax.swing.JTextField jTextField1;
// End of variables declaration
}
V GPA CALCULATOR
ALGORITHM
1. Start the program.
2.Use jlabel, jbutton, jtextfield, jPasswordField in the program.
3.End the program.
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jTextField2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField2ActionPerformed(evt);
}
});
jLabel1.setText("SUBJECT 2");
jLabel2.setText("SUBJECT 1");
jLabel3.setText("SUBJECT 4");
jLabel4.setText("SUBJECT 3");
jLabel5.setText("SUBJECT 6");
jLabel6.setText("SUBJECT 5");
jLabel7.setText("LAB 1");
jLabel9.setText("GRADE");
jLabel10.setText("CREDIT");
jTextField02.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField02ActionPerformed(evt);
}
});
jButton1.setText("Calculate !");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.T
RAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
70, Short.MAX_VALUE)
.addComponent(jLabel10)
.addGap(25, 25, 25))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addGap(24, 24, 24)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addComponent(jLabel3)
.addComponent(jLabel1)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel6)
.addComponent(jLabel2)
.addComponent(jLabel7)
.addComponent(jLabel8))
.addGap(29, 29, 29)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING, false)
.addComponent(jTextField1)
.addComponent(jTextField2)
.addComponent(jTextField3)
.addComponent(jTextField4)
.addComponent(jTextField5)
.addComponent(jTextField6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addComponent(jTextField02)
.addComponent(jTextField01)
.addComponent(jTextField03)
.addComponent(jTextField04)
.addComponent(jTextField06)
.addComponent(jTextField05,
javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jTextField08,
javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jTextField07,
javax.swing.GroupLayout.Alignment.TRAILING))))
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(jButton1)
.addGap(71, 71, 71))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(22, 22, 22)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jLabel9)
.addComponent(jLabel10))
.addGap(27, 27, 27)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jTextField1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)
.addComponent(jTextField01,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jTextField2,
javax.swing.GroupLayout.PREFERRED_SIZE,
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jTextField3,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(jTextField03,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jTextField4,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(jTextField04,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jTextField6,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5)
.addComponent(jTextField06,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(27, 27, 27)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jLabel7)
.addComponent(jTextField7,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField07,
javax.swing.GroupLayout.PREFERRED_SIZE,
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jLabel8)
.addComponent(jTextField8,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField08,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELAT
ED)
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
31, Short.MAX_VALUE)
.addComponent(jTextField9,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(19, 19, 19))
);
pack();
}// </editor-fold>
int csum=0;
int val=1;
float GPA;
int a[]=new int[9];
int c[]=new int[9];
char[] m= new char[8];
a[0]=Integer.parseInt(jTextField01.getText());
a[1]=Integer.parseInt(jTextField02.getText());
a[2]=Integer.parseInt(jTextField03.getText());
a[3]=Integer.parseInt(jTextField04.getText());
a[4]=Integer.parseInt(jTextField05.getText());
a[5]=Integer.parseInt(jTextField06.getText());
a[6]=Integer.parseInt(jTextField07.getText());
a[7]=Integer.parseInt(jTextField08.getText());
for(int i=0;i<8;i++)
csum=csum+a[i];
for(int i=0;i<8;i++)
{
if(m[i]=='o')
c[i]=10;
if(m[i]=='a')
c[i]=9;
if(m[i]=='b')
c[i]=8;
if(m[i]=='c')
c[i]=7;
if(m[i]=='d')
c[i]=6;
if(m[i]=='f')
c[i]=0;
}
for(int i=0;i<8;i++)
val = c[i]*a[i]+val;
jTextField9.setText(" "+GPA);
}
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton1)
.addGap(42, 42, 42)
.addComponent(jLabel2,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(49, 49, 49))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addGroup(layout.createSequentialGroup()
.addGap(57, 57, 57)
.addComponent(jSlider1,
javax.swing.GroupLayout.PREFERRED_SIZE, 253,
javax.swing.GroupLayout.PREFERRED_SIZE))
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(43, 43, 43)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
18, Short.MAX_VALUE)
.addComponent(jSlider1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2,
javax.swing.GroupLayout.PREFERRED_SIZE, 190,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGap(77, 77, 77)
pack();
}// </editor-fold>
int i=jSlider1.getValue();
System.out.println(""+i);
jLabel2.setVisible(true);
if(i<=30)
jLabel2.setIcon(img1);
if((i<=70)&&(i>=31))
jLabel2.setIcon(img2);
if((i<=100)&&(i>=71))
jLabel2.setIcon(img3);
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addComponent(jLabel2,
javax.swing.GroupLayout.PREFERRED_SIZE, 68,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap(130, Short.MAX_VALUE)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(tf1, javax.swing.GroupLayout.PREFERRED_SIZE,
158, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(236, 236, 236))
); layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton1,
javax.swing.GroupLayout.PREFERRED_SIZE, 33,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30)
.addComponent(jLabel2,
javax.swing.GroupLayout.PREFERRED_SIZE, 27,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 267,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(134, Short.MAX_VALUE))
); pack();
}// </editor-fold>//GEN-END:initComponents
private void tf1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_tf1ActionPerformed
// TODO add your handling code here:
java.util.logging.Logger.getLogger(ex3.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(ex3.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(ex3.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ex3.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
} //</editor-fold>
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ex3().setVisible(true);
}
});
} //Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
private javax.swing.JLabel jLabel1;
OUTPUT
ALGORITHM
1. Start the program.
2. Use jcombobox, jlabel in the program.
3. End the program.
SOURCE CODE
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
A()
{
BRICS = new String[]{"Russia", "India", "South Africa", "Brazil", "China"};
if= new JFrame("JComboBox");
combo= new JComboBox<String>(BRICS);
label1 = new JLabel();
jf.add(combo);
combo.addActionListener(this);
jf.setLayout(new FlowLayout());
jf.setSize(210,200);
jf.setVisible(true);
}
public void actionPerformed(ActionEvent ae)
{
JComboBox cb = (JComboBox)ae.getSource();
label1.setText( ((String)cb.getSelectedItem()) + " is selected");
jf.add(label1);
jf.setVisible(true);}}
RESULT
Thus swing GUI applications are implemented using java programs.
I SINGLE THREAD
ALGORITHM
1. Start the program.
2. Extend the thread class.
3. End the program.
SOURCE CODE
package class_and_objects;
II ASYNCHRONOUS MULTITHREADING
ALGORITHM
1. Start the program.
2. Implement multithreading in asynchronous way.
3. End the program.
SOURCE CODE:
package class_and_objects;
int n=3,m=0,flag=0,i;
m=n/2;
for(i=2;i<=m;i++) {
if(n%i==0) {
System.out.println(n+"is not a prime no");
flag=1;
break;
}
}
if(flag==0) {
System.out.println(n+"is a prime number");
}
}
}
public class Asynchronous_thread {
static void Tname() {
Thread t=Thread.currentThread();
String name=t.getName();
System.out.println("Thread name:\t"+name);
}
import java.io.*;
import java.util.*;
// Driver class
public class Synchronous_class
{
public static void main(String args[])
{
Sender snd = new Sender();
ThreadedSend S1 =
new ThreadedSend( " Thanks for using the Vodafone service " , snd );
ThreadedSend S2 =
new ThreadedSend(" Hello your recharge is successful " , snd );
IV ASYNCHRONOUS MULTITHREADING
USING JOIN
ALGORITHM
1. Start the program.
2. Implement multithreading in asynchronous way using join method.
3. End the program.
/**
* Calculate average of numbers. Sum all the int values and divide it by
* total count.
*/
private static class Average implements Runnable {
private Integer[] values;
private int mean;
Average(Integer[] values) {
this.values = values;
}
@Override
public void run() {
mean = 0;
int n = values.length;
for (int i : values) {
mean += i;
/**
* Sorts the given int list and calculates the median value. If size is
* even, the mean of middle and middle-1.
*
*/
private static class Median implements Runnable {
private Integer[] values;
private int median;
Median(Integer[] values) {
this.values = values;
}
@Override
public void run() {
List<Integer> sortedList = Arrays.asList(values);
Collections.sort(sortedList);
int n = values.length;
int middle = n / 2;
if (n % 2 == 0) {
}
}
OUTPUT
int n=3,m=0,flag=0,i;
m=n/2;
for(i=2;i<=m;i++) {
if(n%i==0) {
System.out.println(n+"is not a prime no");
flag=1;
break;
}
}
if(flag==0) {
System.out.println(n+"is a prime number");
}
}
}
RESULT
Thus threading is implemented using java.
<html>
<body>
<img src=” C:\Users\GodShiva\Desktop\pussycat.jpg”
alt=”pussy cat” align=”left”>
</body>
</html>
OUTPUT
<html>
<body>
To see the wall of cricket:
<a href="Dravid.html">
Click Here
</a>
</body>
</html>
(Dravid.html)
<html>
<body>
<center>
<img src="C:\Users\GodShiva\Desktop\TestHero.jpg"
alt="Ragul Dravid" width="500" height="500">
</center>
</body>
</html>
<html>
<head>
<title>MARK LIST</title>
</head>
<body>
<center><table WIDTH="100" border="2" CELLSPACING="1">
<tr>
<th>NAME<th>PDS I<TH>WEB TECH<th>C# & .NET
</tr>
<tr>
| HTML SoftNotes 20 March 2019, 12:48:12 PM |
OUTPUT
<!doctype html>
<html>
<head>
<title>Playing Video</title>
It provides play, pause, full
</head> screen option, etc, …
<body>
<center>
<video width="720" height="520" controls>
<source src="C:\Users\Krishna\Desktop\HTML5
Lab\vadivelu1.mp4" type="video/mp4"/>
</video> Video Format
</center>
</body> Video Path
</html>
RESULT
Thus the websites creation using HTML5 tags are implemented and
tested successfully.
body
{
background-color: #00b1c1;
text-align: center; Design the <div> tag using CSS
}
.dd
{
padding:2%;
color: white;
background-color: #4f5b65;
width: 96%;
font-size: 21px;
border-color: #ef9421;
border-style:solid;
Design the <h3> tag using internal
align-self: center
CSS
}
h3
{
color: white;
NOTE
The page above returns the server response like host didn’t send any
data due to not mentioned the server side languages like php, python,
jsp, asp.net, etc,… in action attribute of form element.
RESULT
Thus the servlet program was created and implemented using java
successfully.
import java.sql.*;
import javax.servlet.ServletException;
import javax.servlet.http.*;
public class Scores extends HttpServlet {
Connection con;
PreparedStatement pt;
ResultSet rs;
int sn;
String uname;
int a1,a2,a3,a4,a5,total;
String isql="insert into Table1 values(?,?,?,?)";
static int c=1;
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
// establishing connection to database
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:webtech");
//out.println("<h3>DB is connected...</h3>");
}
RESULT
Thus the servlet based web application with JDBC database was
successfully implemented.
SOURCE CODE
(index.jsp)
<html>
<body>
<center><h1>Hello World</h1></center>
</body>
</html>
PROJECT STRUCTURE
NOTE
Whenever user submits the form (pressing submit button), then next
page will be called via form action tag
submit button Event Source (Event creator)
action tag Event Handler
Here, the event handler (implicit calling) will be called automatically,
whenever the submit button is pressed by the user.
Submit button
This is a predefined event handler. Here user should write code via JSP
/ servlet to handle the appropriate event.
RESULT
Thus the development of JSP web application was implemented
successfully.
OUTPUT
OUTPUT
SOURCE CODE
(shiva.py)
# define function
def disp():
# read a number (string format)
a=input("Enter the 1st number: ")
# convert string number to int number
a=int(a)
# read another number (string format)
OUTPUT
SOURCE CODE
(shiva.py)
# define function
def disp():
# read a name as string
name=input("Enter person name \t: ")
# read id and convert it to int
id=int(input("Enter id number \t: "))
# read salary and convert it float type
pack=float(input("Enter the salary \t: "))
OUTPUT
SOURCE CODE
(welcome.py)
print("---------------------------------------------")
print("\t Python Constructor")
print("---------------------------------------------")
# class definition
class Hello:
def __init__(self):
print("Good Morning")
# object creation and calling constructor (default constructor)
obj=Hello()
OUTPUT
RESULT
Thus the basic programs of python applications were implemented
successfully.
SQLITE3
Download the following sqlite3 softwares in the SQLite home page
1. Download sqlite-dll-win64-x64-3360000.zip (32 bit) or sqlite-dll-
win64-x64-3360000.zip (64bit)
2. Download sqlite-tools-win32-x86-3360000.zip
Extract the zip files listed above and add the extracted contents in the
folder of your computer like c/sqlite
I. DATABASE CREATION
SOURCE CODE
import sqlite3
# create the database by starting the connection with sqlite
try:
con=sqlite3.connect("ganesh.db")
print("Database is successfully created...")
except Error:
print("Error in creating the database")
finally:
con.close()
OUTPUT
OUTPUT
OUTPUT
V. DATA UPDATION
SOURCE CODE
import sqlite3
print("---------------------------------")
print("\tData Updation")
print("---------------------------------")
# connect and open the existing DB
con=sqlite3.connect("ganesh.db")
# define the update query
usql="update stud set name='Velan', dept='SE' where id=5"
# execute the update query using execute() method of connection object
con.execute(usql)
con.commit()
print("One Record is successfully updated...")
OUTPUT
OUTPUT
RESULT
Thus the database sqlite3 CRUD operations are implemented using
python 3.