Vishwajeet Srivastav IT Project Work

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

InformatiON

TECHNOLOGY
Programming file
NAME – VISHWAJEET SRIVASTAV
CLASS – XIIth- ENAME :
ROLL N0. –
CLASS : xii
SUBJECT – INFORMATION TECHNOLOGY
ROLL NO:
PART-1
JAVA
NET
BEANS
Q-1 Write a code in Java to enter two numbers and swap them.

private void inBtnActionPerformed(java.awt.event.ActionEvent evt) {


int a=0,b=0,c=0;
a=Integer.parseInt(n1TF.getText());
b=Integer.parseInt(n2TF.getText());
c=a;
a=b;
b=c;
n1TF.setText(""+a);
n2TF.setText(""+b);
Q-2 Write a code in Java to enter a number and check whether it is
positive or Negative.

private void showBtnActionPerformed(java.awt.event.ActionEvent evt) {


int n;
n=Integer.parseInt(nTF.getText());
{
if(n>0)
{
tf.setText(“Positive”);
}
else
{
tf.setText(“Negative”);
}}
Q-3 Write a code in Java to enter two numbers and display the greatest
one in the textfield.

private void CMDActionPerformed(java.awt.event.ActionEvent evt) {


int a=Integer.parseInt(atxt.getText());
int b=Integer.parseInt(btxt.getText());
if(a>b)
{
Gtxt.setText(" "+a);
}
else
{
Gtxt.setText(" "+b);
}
Q-4 Write a code in Java to enter a number in a textfield and check
whether the number is even or odd on the label.

private void CMDActionPerformed(java.awt.event.ActionEvent evt) {


int m=Integer.parseInt(txt.getText());
if(m%2= = 0)
{
txt1.setText(“Even Number”);
}
else
{
txt1.setText(“Odd Number”);
}}
Q-4 Write a code to enter a number in ntf and check the multiple of
(3,5and 7) .

private void CMDActionPerformed(java.awt.event.ActionEvent evt) {


int n=Integer.parseInt(nTF.getText());
if(thRB.isSelected()==true)
{
if(n%3==0)
lbl,setText("multiple of 3");
else
lbl.setText ("not multiple of 3");
}
else if(fiRB.isSelected()==true)
{
if(n%5==0)
lbl.setText("multiple of 5");
else
lbl.setText("not multiple of 5");
}
else if(sRB.isSelected()==true)
{
if(n%7==0)
lbl.setText("multiple of 7");
else
lbl.setText("not multiple of 7");
}
else
{
lbl.setText(“Not a Multiple of 3,5 and 7”); }}

Q-5 Write a code to enter two numbers and accept choice from the user
according to the selection done by him in the check box and display the
desired result.

private void cmdcalActionPerformed(java.awt.event.ActionEvent evt) {


int a=Integer.parseInt(n1tf.getText());
int b=Integer.parseInt(n2tf.getText());
if(achk.isSelected()==true)
albl.setText(""+(a+b));
else
albl.setText("0");
if(schk.isSelected()==true)
slbl.setText(""+(a-b));
else
slbl.setText("0");
if(mchk.isSelected()==true)
mlbl.setText(""+(a*b));
else
mlbl.setText("0");
if(dchk.isSelected()==true)
dlbl.setText(""+(a/b));
else
dlbl.setText("0");
}
private void cmdextActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}

private void cmdclrActionPerformed(java.awt.event.ActionEvent evt) {


n1tf.setText("");
n2tf.setText("");
albl.setText("0");
slbl.setText("0");
mlbl.setText("0");
dlbl.setText("0");
achk.setSelected(false);
schk.setSelected(false);
mchk.setSelected(false);
dchk.setSelected(false);
}

Q-6 Write a code to enter a number from 1 to 7 and display the


corresponding days of the week in the textfield.

private void shBtnActionPerformed(java.awt.event.ActionEvent evt) {


int n=Integer.parseInt(nTF.getText());

switch(n)
{
case 1:

ansTF.setText(“monday”);

break;

case 2:

ansTF.setText(“tuesday”);

break;

case 3:

ansTF.setText(“wednesday”);

break;

case 4:

ansTF.setText(“thursday”);

break;

case 5:

ansTF.setText(“friday”);

break;

case 6:

ansTF.setText(“saturday”);

break;

case 7:
ansTF.setText(“sunday”);

break;

default :

ansTF.setText(“Wrong Choice”);

Q-6 Write a code to print the table of the number entered by the user.

private void ptBtnActionPerformed(java.awt.event.ActionEvent evt) {


int a=1,n=0;
n=Integer.parseInt(nTF.getText());
for(int i=1;i<=10;i++)
{
a=n*i;
System.out.println(n+"*"+i+"="+a);
}
}

private void exitBtnActionPerformed(java.awt.event.ActionEvent evt) {


System.exit(0);}
Q- 7 Write a code to enter a number and check whether the number
is Palindrome or not.

private void cmdchkActionPerformed(java.awt.event.ActionEvent evt) {


int n=Integer.parseInt(ntxt.getText());
int y=n;
int s=0;
int r;
while(n>0)
{
r = n%10;
s = (s*10)+r;
n =n/10;
}
if(y==s)
dlbl.setText("Itis a palimdrome");
else
dlbl.setText("It is not a palimdrome");

private void cmdextActionPerformed(java.awt.event.ActionEvent evt) {


System.exit(0);
}

Q-8 Write a code to print the factorial of a number entered by the user.
private void factBtnActionPerformed(java.awt.event.ActionEvent evt) {
int ans=1;
int n=Integer.parseInt(nTF.getText());
for (int i=1;i<=n;i++)
{ans=ans*i;
}
System.out.println(ans);
}

Q-9 Write a code to accept a number from the user and print whether it is
prime number or not.

private void CMDDISActionPerformed(java.awt.event.ActionEvent evt) {


int n1=Integer.parseInt(n1txt.getText());
int n2=Integer.parseInt(n2txt.getText());
String s="";
int x;
for(int i=n1;i<=n2;i++)
{
int c=0;
for(x = 2;x<i;x++)
{
if (i%x==0)
c=1;
}
if (c==0)
s=s+x+" ";
}
darea.setText(s);
}

Q-10 Write a code to enter temperature in a textfield and convert it into


Celsius to Fahrenheit and vice versa according to the selected choice.

private void CMDCONActionPerformed(java.awt.event.ActionEvent evt) {


float t1=Integer.parseInt(t1tf.getText());
float t2=0;
if(c2frb.isSelected()==true)
t2= (9*(t1+32))/5;
else
t2= 5*(t1-32)/9;
t2tf.setText(""+t2);
}

private void CMDEXTActionPerformed(java.awt.event.ActionEvent evt) {


System.exit(0);
}

Q-11 Write a code to enter name and Fees of the members in the
respective textfields . On the basis of the type of the membership and the
selected sports, Calculate Total fees that has to be paid by the member.

private void CALCBUTActionPerformed(java.awt.event.ActionEvent evt) {


String n=txt.getText();
int fees=Integer.parseInt(ftxt.getText());
if(gopt.isSelected()==true)
{
fees=fees-fees*12/100;
}
if(sopt.isSelected()==true)
{
fees=fees-fees*7/100;
}
if(swchk.isSelected()==true)
{
fees=fees+600;
}
if(schk.isSelected()==true)

{
fees=fees+700;
}
if(bchk.isSelected()==true)
{
fees=fees+450;
}
tftxt.setText(""+fees);
}

Q-12 The state Electricity Board generates monthly electricity bill to


be computed as follows:
Minimum Rs 500 for first 100 units.
Plus Rs 7.00per unit for next 100 units.
Plus Rs7.50 per unit for next 100 units.
Plus Rs8.00 per unit any unit beyond 300.

private void showBtnActionPerformed(java.awt.event.ActionEvent evt) {


double u,bill=0;
u=Double.parseDouble(uTF.getText());
if(u<=100)
bill=500;
else
if(u>=100&&u<=200)

bill=500+(u-100)*7;
else
if(u<=200&&u<=300)

bill=500+700+750+(u-200)*7.50;
else
if(u>=300)

bill=500+700+750+800+(u-300)*8;
billTF.setText(""+bill);
}

Q-13 A networking company decided to computerize its employee


salary develop an application to store employee’s personal data which
will be saved in the back end. The front end should accept name, basic
salary & calculate DA, HRA and Net Salary.

private void calBtnActionPerformed(java.awt.event.ActionEvent evt) {


String name;
double s,da=0,hra=0,ns;
s=Double.parseDouble(sTF.getText());

if(s>=4000)

{
hra=(s*37)/100;

da=(s*35)/100;

else

if(s>=20000)

hra=(s*32)/100;

da=(s*25)/100;

else

{
hra=(s*30)/100;

da=(s*25)/100;
}

ns=s+da+hra;

nsTF.setText(""+ns);

daTF.setText(""+da);

hraTF.setText(""+hra);}
PART-2
SQL
Consider the following relation ‘STUDENT’

ROLL NAME AGE DEPARTMENT DATE_ ADM FEES SEX


NO
100 SANJANA 24 COMPUTER 10-JAN-97 1200 F

107 SHALINI 31 HISTORY 5-MAY-98 800 F

110 SANJAY 20 HINDI 6-AUG-99 600 M

115 MANI 19 HISTORY 10-JAN-99 900 M

120 POONAM 37 ENGLISH 10-OCT-99 500 F

125 SURYA 35 HINDI 11-DEC-97 800 M

130 SHIKHA 26 COMPUTER 31-JUL-97 1300 F

132 RAJA 29 COMPUTER 1-JAN-99 1500 M

Write the SQL queries for the following:

Q1.To Create the above table (the following constraint applied on the above table
Roll No as PRIMARY
KEY and name as NOT NULL).
SQL>CREATE TABLE STUDENT (ROLLNO NUMBER(3)PRIMARY KEY, NAME VARCHAR(20)
NOT NULL, AGE NUMBER92), DEPARTMENT VARCHAR(15), DATE_ADM DATE, FEES
NUMBER(4), SEX CHAR(1));

OUTPUT

Table created

Q2.To insert the above records.

SQL>INSERT INTO STUDENT VALUES (100, ‘SANJANA’, 24, ‘COMPUTER’, ‘10-JAN-97’,1200, ‘F ’);

OUTPUT
1 row inserted

SQL>INSERT INTO STUDENT VALUES (110, ‘SANJAY’, 20, ‘HINDI’, ‘6-AUG-99’, 600, ‘M’);
OUTPUT
1 row inserted

SQL>INSERT INTO STUDENT VALUES (115, ‘MANI’, 19, ‘HISTORY’, ‘10-JAN-99’, 900, ‘M’);

OUTPUT
1 row inserted

SQL>INSERT INTO STUDENT VALUES (120, ‘POONAM’, 37, ‘ENGLISH’, ‘10-OCT-99’, 500, ‘F’);

OUTPUT
1 row inserted

SQL>INSERT INTO STUDENT VALUES (125, ‘SURYA’, 35, ‘HINDI’, ‘11-DEC-97’, 800, ‘M’);

OUTPUT
1 row inserted

SQL>INSERT INTO STUDENT VALUES (130, ‘SHIKA’, 26, ‘COMPUTER’, ‘31-JUL-97’, 1300’, ‘F ‘);

OUTPUT
1 row inserted

SQL>INSERT INTO STUDENT VALUES (132, ‘RAJA’, 29, ‘COMPUTER’, ‘1-JAN-99’, 1500, ‘M’);

OUTPUT
1 row inserted

Q3.To display all the information of female student.

SQL>SELECT * FROM STUDENT WHERE SEX= ‘F ’;

OUTPUT

ROLL NO NAME AGE DEPARTMENT DATE_ ADM FEES SEX


100 SANJANA 24 COMPUTER 10-JAN-97 1200 F
107 SHALINI 31 HISTORY 5-MAY-98 800 F
120 POONAM 37 ENGLISH 10-OCT-99 500 F
130 SHIKHA 26 COMPUTER 31-JUL-97 1300 F

Q4.To display name of those student whose age is between 20 and 25.

SQL>SELECT NAME FROM STUDENT WHERE AGE BETWEEN 20 AND 25;

OUTPUT

SANJAY
SANJANA
Q5.To display name and department of all the students whose fees is greater than 1000
SQL>SELECT NAME, DEPARTMENT FROM STUDENT WHERE FEES>1000;

OUTPUT

NAME DEPARTMENT
SANJANA COMPUTER
SHIKHA COMPUTER
RAJA COMPUTER

Q6.To display name and age of the student who either belong to Hindi, History or
English department.

SQL>SELECT NAME, AGE FROM STUDENT WHERE DEPT IN (‘HINDI’, ‘HISTORY’, ‘ENGLISH’);

OUTPUT

NAME AGE
SHALINI 31
SANJAY 20
MANI 19
POONAM 37
SURYA 35

Q7.To display name of available department.


SQL>SELECT DISTINCT(DEPARTMENT) FROM STUDENT;

OUTPUT

DEPARTMENT
COMPUTER
HISTORY
HINDI
ENGLISH

Q8.To count total no of student whose name starts with‘s’.

SQL>SELECT COUNT(*)FROM STUDENT WHERE NAME LIKE ‘S%’;

OUTPUT
5

Q9.To display department and total amount of fees collected by each


department.
SQL>SELECT DEPARTMENT, SUM (FEES) FROM STUDENT GROUP BY DEPARTMENT;

OUTPUT
DEPARTMENT SUM (FEES)
COMPUTER 4000
HISTORY 500
HINDI 1400
ENGLISH 1700
Q10.To display the average fees of female computer students.

SQL>SELECT AVG (FEES) FROM STUDENT WHERE SEX = ‘F’ AND DEPARTMENT =
‘COMPUTER’;

OUTPUT
1350

Q11.To display Name, Age and Date of Admission of the student according to the
alphabetic orders of their name.

SQL>SELECT NAME, AGE, DATE_ADM FROM STUDENT ORDER BY NAME;

OUTPUT
NAME AGE DATE_ ADM

MANI 19 10-JAN-99
POONAM 37 10-OCT-99
RAJA 29 1-JAN-99
SANJANA 24 10-JAN-97
SANJAY 20 6-AUG-99
SHALINI 31 5-MAY-98
SHIKHA 26 31-JUL-97
SURYA 35 11-DEC-97

Q12.To Count the total number of department where number of student are more
then 2.
SQL>SELECT COUNT (*) FROM STUDENT GROUP BY DEPARTMENT HAVING COUNT (NAME)
>2;

OUTPUT
1

Q13.To increase the fees by 10% for all the student .

SQL> UPDATE STUDENT SET FEES =FEES+ (FEES*10)/100;

OUTPUT
8 ROWS UPDATED

Q14. To delete the record of those students whose age is greater than and equal to 35 and
Date _of _Adm is less than 01-Jan-99.

SQL> DELETE FROM STUDENT WHERE AGE >=35 AND DATE_ADM < ‘01-JAN-99’;

OUTPUT
2 ROW DELETED

Q15. To delete the above table from memory permanently.


SQL> DROP TABLE STUDENT;

OUTPUT
TABLE DROPPED.

You might also like