0% found this document useful (0 votes)
34 views37 pages

It Class 11

This document is a practical file for the Information Technology subject, detailing various Java GUI applications and SQL queries. It includes a structured index of tasks such as string concatenation, arithmetic operations, and database management queries. Each task is accompanied by code snippets demonstrating the implementation in Java and SQL.

Uploaded by

Aksa
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)
34 views37 pages

It Class 11

This document is a practical file for the Information Technology subject, detailing various Java GUI applications and SQL queries. It includes a structured index of tasks such as string concatenation, arithmetic operations, and database management queries. Each task is accompanied by code snippets demonstrating the implementation in Java and SQL.

Uploaded by

Aksa
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/ 37

Practical File

On
Information Technology
Subject Code: 802

Submitted By:
Name:________________
Class:________________
RNO:________________

Submitted To:
Name: Mr. Raj Kumar Verma
Designation: PGT (Computer Science)
(Department of Computer Science)

GOBINDGARH PUBLIC SCHOOL, MANDI GOBINDGARH


INDEX
SNO DESCRIPTION PAGE NO
JAVA PROGRAMMS IN NETBEANS IDE
1 Design a GUI application to concatenate (combine) two strings
2 Design a GUI application to calculate simple arithmetic operations.
3 Design a GUI application to calculate Simple Interest
4 Design a GUI application to calculate the sum of digits of three digit
number
5 Design a GUI application to check whether the entered number is even or
odd
6 Design a GUI application to check whether the entered number is positive
or negative
7 Design a GUI application in java to convert temperature from Celsius to
Fahrenheit or vice versa
8 Design a GUI application to perform an operation based on the criteria
input by the user in a radio button
9 Design a GUI application to accept marks of 5 subjects and find out the
total, percentage and also display grade depending on the percentage
10 Design a GUI application to check whether the entered character is Vowel
or Consonant
11 Design a GUI application to find out greatest among three numbers by
using Logical and relational Operators
12 Design a GUI application to check whether the year is leap year or not
13 Design a GUI application to display the day of the week via switch
statement.
14 Design a GUI application to demonstrate the working of Combo Box
DATABASE QUERIES IN MYSQL
1 Write a SQL query to create database
2 Write a SQL query to create a table
3 Write a SQL query to insert values into a table
4 Write a SQL query to display the contents of table
5 Write a SQL query to display specific columns
6 Write a SQL query to display particular record/row
7 Write a SQL query to display records of teachers having salary greater
than 50000
8 Write a SQL query to sort the records “Salary”-wise
9 Write a SQL query to sort the records by “Salary” in descending order
10 Write a SQL query to display the Salary of “Alok”
11 Write a SQL query to display the records of "Female Teachers"
12 Write a SQL query to display the records of the teachers whose gender is
female and salary is greater than 60000
13 Write a SQL query to display the records of teachers whose name starts
with alphabet "A"
14 Write a SQL query to update salary of IP teacher by 10%.
15 Write a SQL query to add primary key in the table
16 Write a SQL query to Add a column in the table
17 Write a SQL query to delete the particular record.
18 Write a SQL queries to count number of tuples and maximum salary of
the teacher
19 Write a SQL query to show salary between 45000 and 65000
20 Write a SQL query to display table where names are Ravi and Alok
21 Write a SQL queries to display average and total salary by grouping
gender-wise.
22 Write a SQL queries to append text before their names.
#1: Design a GUI application to concatenate (combine) two strings
private void btnConcatActionPerformed(java.awt.event.ActionEvent evt)
{
txt3.setText(txt1.getText()+txt2.getText());
}

#2: Design a GUI application to calculate simple arithmetic operations.


private void jButton1ActionPerformed (java.awt.event.ActionEvent evt)
{
int num1, num2, addition;
num1=Integer.parseInt (txtnum1.getText () );
num2=Integer.parseInt (txtnum2.getText () );
addition=num1+num2;
txtaddition.setText (""+addition) ;
}
private void jButton1ActionPerformed (java.awt.event.ActionEvent evt)
{
int num1, num2, subtraction;
num1=Integer.parseInt (txtnum1.getText () );
num2=Integer.parseInt (txtnum2.getText () );
subtraction=num1-num2;
txtsubtraction.setText (""+subtraction) ;
}
private void jButton1ActionPerformed (java.awt.event.ActionEvent evt)
{
int num1, num2, multiplication;
num1=Integer.parseInt (txtnum1.getText () );

1
num2=Integer.parseInt (txtnum2.getText () );
multiplication=num1*num2;
txtmutilplication.setText (""+multiplication) ;
}
private void jButton1ActionPerformed (java.awt.event.ActionEvent evt)
{
int num1, num2, division;
num1=Integer.parseInt (txtnum1.getText () );
num2=Integer.parseInt (txtnum2.getText () );
division=num1/num2;
txtdivision.setText (""+division) ;
}
private void jButton1ActionPerformed (java.awt.event.ActionEvent evt)
{
int num1, num2, remainder;
num1=Integer.parseInt (txtnum1.getText () );
num2=Integer.parseInt (txtnum2.getText () );
remainder=num1%num2;
txtremainder.setText (""+remainder) ;
}

2
3
#3: Design a GUI application to calculate Simple Interest
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
float p,r,t,si;
p=Float.parseFloat(t1.getText());
r=Float.parseFloat(t2.getText());
t=Float.parseFloat(t3.getText());
si=p*r*t/100;
res.setText(""+si);
}

#4: Design a GUI application to calculate the sum of digits of three digit
number. Hint : Suppose user enters 123 the output should be 6(1+2+3).
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
int sum,r1,r2,r3,num;
num=Integer.parseInt(txt1.getText());
r1=num%10;
num=num/10;
r2=num%10;
num=num/10;
r3=num%10;
num=num/10;
sum=r1+r2+r3;
txt2.setText(sum+"");
}

4
5
#5: Design a GUI application to check whether the entered number is even
or odd
private void btnActionPerformed(java.awt.event.ActionEvent evt)
{
int a;
a=Integer.parseInt(txt.getText());
if (a%2==0)
txt1.setText("even");
else
txt1.setText("odd");
}

#6: Design a GUI application to check whether the entered number is


positive or negative.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
int a;
a=Integer.parseInt(txt1.getText());
if (a<0)
txt2.setText("NEGATIVE");
else
txt2.setText("POSITIVE");
}

6
7
#7: Design a GUI application in java to convert temperature from Celsius to
Fahrenheit or vice versa.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
float a,f;
a=Float.parseFloat(cel.getText());
f=(a*9/5)+32;
fer.setText(""+f);
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt)
{
float a,c;
a=Float.parseFloat(fer.getText());
c=(a-32)*5/9;
cel.setText(""+c);
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt)
{
cel.setText("");
fer.setText("");
}

8
9
#8: Design a GUI application to perform an operation based on the criteria
input by the user in a radio button

private void rbADDActionPerformed(java.awt.event.ActionEvent evt)


{
int a,b,c;
if (rbADD.isSelected()) //It will check and set the state of radio button to true when it is
selected
{

rbSUB.setSelected(false); /* To select only one radio button


rbMUL.setSelected(false); among all the five buttons , we have to set the state of
rbDIV.setSelected(false); other radio buttons to false
rbREM.setSelected(false); */

a=Integer.parseInt(n1.getText());
b=Integer.parseInt(n2.getText());

c=a+b;
txtRes.setText(""+c);
}
//Code to perform Subtraction
private void rbSUBActionPerformed(java.awt.event.ActionEvent evt)
{
int a,b,c;
if (rbSUB.isSelected()) // Now state of subtract radio button will be true
{
rbADD.setSelected(false); /*
rbMUL.setSelected(false);
rbDIV.setSelected(false); set state of others radio buttons to false
rbREM.setSelected(false); */

a=Integer.parseInt(n1.getText());
b=Integer.parseInt(n2.getText());
c=a-b;
txtRes.setText(""+c);

10
}
}

//Code to perform Multiplication


private void rbMULActionPerformed(java.awt.event.ActionEvent evt)
{
int a,b,c;
if (rbMUL.isSelected()) //Now state of Multiplication radio button is set to true
{
rbADD.setSelected(false); /*
rbSUB.setSelected(false); Same code
rbDIV.setSelected(false);
rbREM.setSelected(false); */

a=Integer.parseInt(n1.getText());
b=Integer.parseInt(n2.getText());
c=a*b;
txtRes.setText(""+c);

}
}
//Code to perform division
private void rbDIVActionPerformed(java.awt.event.ActionEvent evt)
{
int a,b;
float c;
if (rbDIV.isSelected()) //Now state of division radio button is set to true
{
rbADD.setSelected(false); /*
rbSUB.setSelected(false); Same code
rbMUL.setSelected(false);
rbREM.setSelected(false); */

a=Integer.parseInt(n1.getText());
b=Integer.parseInt(n2.getText());
c=(float)a/b;
txtRes.setText(""+c);

11
}
}
//Code to find out remainder
private void rbREMActionPerformed(java.awt.event.ActionEvent evt)
{
int a,b,c;
if (rbREM.isSelected()) //Now state of remainder radio button is set to true
{
rbADD.setSelected(false); /*
rbSUB.setSelected(false); Same code
rbMUL.setSelected(false);
rbDIV.setSelected(false); */

a=Integer.parseInt(n1.getText());
b=Integer.parseInt(n2.getText());
c=a%b;
txtRes.setText(""+c);
}

12
13
#9: Design a GUI application to accept marks of 5 subjects and find out the
total, percentage and also display grade depending on the percentage.
//Code to calculate the total of five subjects
private void btnTotalActionPerformed(java.awt.event.ActionEvent evt)
{ int s1,s2,s3,s4,s5,total;
s1=Integer.parseInt(txtEnglish.getText());
s2=Integer.parseInt(txtMath.getText());
s3=Integer.parseInt(txtScience.getText());
s4=Integer.parseInt(txtSST.getText());
s5=Integer.parseInt(txtIT.getText());
total=s1+s2+s3+s4+s5;
txtTotal.setText(total+"");
}
//Code to find out the Percentage and analyze the grade on the basis of percentage via
if-else-if statement
private void btnPerActionPerformed(java.awt.event.ActionEvent evt)
{ float per;
per=Float.parseFloat(txtTotal.getText())/5;
txtPer.setText(per+"");
if(per>=90)
lbl2.setText("A+");
else if (per>=85 && per<90)
lbl2.setText("A");
else if(per>=80 && per<85)
lbl2.setText("B+");
else if(per>=75 && per<80)
lbl2.setText("B");
else
lbl2.setText("C"); }

14
15
#10: Design a GUI application to check whether the entered character is
Vowel or Consonant
private void btnChkActionPerformed(java.awt.event.ActionEvent evt)
{
char ch;
ch=txtChar.getText().charAt(0);
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
txtChar.setText("It is a Vowel");
else
txtChar.setText("It is a consonant");
}
//Code to clear the textbox.
private void txtClearActionPerformed(java.awt.event.ActionEvent evt)
{
txtChar.setText("");
}
Q: What will happen if you will input vowel in capital letter?
Ans: You have to write conditions for both small and capital letters like:
if( (ch=='a'|| ch==’A’) || (ch=='e'|| ch==’E’) || (ch=='i' || ch==’I’) || (ch=='o'||ch==’O’) ||
(ch=='u' || ch==’U’) )
txtChar.setText("It is a Vowel");
else
txtChar.setText("It is a consonant");

16
17
#11: Design a GUI application to find out greatest among three numbers by
using Logical and relational Operators
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
int a,b,c;
a=Integer.parseInt(txtNum1.getText()); //code to convert string to integer
b=Integer.parseInt(txtNum2.getText());
c=Integer.parseInt(txtNum3.getText());
if(a>b&&a>c)
lbl.setText(a+" is greatest");
else if(b>a&&b>c)
lbl.setText(b+" is greatest");
else
lbl.setText(c+" is greatest");
}

#12: Design a GUI application to check whether the year is leap year or not.
private void btn1ActionPerformed(java.awt.event.ActionEvent evt)
{
int year;
year=Integer.parseInt(txt1.getText());
if(year%400==0||(year%4==0&&year%100!=0))
txt2.setText("leap year");
else
txt2.setText("not a leap year");
}

18
19
#13: Design a GUI application to display the day of the week via multi-way
decision making statement.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
int choice;
choice=Integer.parseInt(day.getText());
switch(choice)
{
case 1:
week.setText("Monday");
break;
case 2:
week.setText("Tuesday");
break;
case 3:
week.setText("Wednesday");
break;
case 4:
week.setText("Thursday");
break;
case 5:
week.setText("Friday");
break;
case 6:
week.setText("Saturday");
break;
case 7:
week.setText("Sunday");
break;
default:
week.setText("Wrong Input");
break;

20
21
#14: Design a GUI application to demonstrate the working of Combo Box

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)


{
int pri,time;
double si,roi=1;
pri=Integer.parseInt(p.getText());
time=Integer.parseInt(t.getText());
switch(cb.getSelectedIndex())
{
case 0:
roi=1.5;
break;
case 1:
roi=1.75;
break;
case 2:
roi=2.25;
break;
case 3:
roi=2.75;
break;
}

si=(pri*roi*time)/100;

res.setText(si+"");

22
23
#1: Write a SQL query to create database

#2: Write a SQL query to create a table

24
#3: Write a SQL query to insert values into a table

#4: Write a SQL query to display the contents of table

25
#5: Write a SQL query to display specific columns

#6: Write a SQL query to display particular record

26
#7: Write a SQL query to display records of teachers having
salary greater than 50000

#8:Write a SQL query to sort the records “Salary”-wise

27
#9: Write a SQL query to sort the records by “Salary”
in descending order

#10: Write a SQL query to display the Salary of “Alok”

28
#11: Write a SQL query to display the records of
"Female Teachers"

#12: Write a SQL query to display the records of the


teachers whose gender is female and salary is greater
than 60000

29
#13: Write a SQL query to display the records of
teachers whose name starts with alphabet "A"

#14: Write a SQL query to update salary of IP teacher


by 10%.

30
#15: Write a SQL query to add primary key in the table

#16: Write a SQL query to add a column in the table

31
#17: Write a SQL query to delete the particular record.

#18: Write a SQL queriea to count number of tuples


and maximum salary of the teacher

32
#19: Write a SQL query to show salary between 45000
and 65000

#20: Write a SQL query to display table where names


are Ravi and Alok

33
#21: Write a SQL queries to display average and total
salary by grouping gender-wise.

#22: Write a SQL queries to append text before their


names.

34

You might also like