0% found this document useful (0 votes)
9 views30 pages

It File

The document outlines various Java GUI application designs for performing tasks such as string concatenation, arithmetic operations, calculating simple interest, and checking number properties (even/odd, positive/negative). It also includes applications for converting temperatures, calculating grades based on marks, and determining whether a character is a vowel or consonant. Additionally, it contains SQL queries for database operations including creating tables, inserting values, and querying records based on specific criteria.

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)
9 views30 pages

It File

The document outlines various Java GUI application designs for performing tasks such as string concatenation, arithmetic operations, calculating simple interest, and checking number properties (even/odd, positive/negative). It also includes applications for converting temperatures, calculating grades based on marks, and determining whether a character is a vowel or consonant. Additionally, it contains SQL queries for database operations including creating tables, inserting values, and querying records based on specific criteria.

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/ 30

#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 operation.
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 () );
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) ;
}
#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+"");
}
#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");
}
#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: 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);
}
}

//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);
}
}
//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);
}
#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");
}
#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");
#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");
}
Write a SQL query to create database

Write a SQL query to create a table


Write a SQL query to insert values into a table

Write a SQL query to display content of the table

Write a SQL query to display specific columns


Write a SQL query to display particular record

Write a SQL query to display records of teachers having


salary greater than 50000
Write a SQL query to sort the records “Salary”-wise
Write a SQL query to sort the records by “Salary” in
descending order

Write a SQL query to display the Salary “Alok”


Write a SQL query to display the records of "Female
Teachers"

Write a SQL query to display the records of the


teachers whose gender is female and salary is greater
than 60000
Write a SQL query to display the records of teachers
whose name starts with alphabet "A"

Write a SQL query to update salary of IP teacher by


10%.
Write a SQL query to add primary key in the table

Write a SQL query to Add a column in the table


Write a SQL query to delete the particular record.

Write a SQL queriea to count number of tuples and


maximum salary of the teacher
Write a SQL query to show salary between 45000 and
65000

Write a SQL query to display table where names are


Ravi and Alok
Write a SQL queries to display average and total
salary by grouping gender-wise.

Write a SQL queries to concate Mr. and Ms.as a prefix


before their names.

You might also like