Documente Academic
Documente Profesional
Documente Cultură
String S1=jTextField1.getText();
String S2=jTextField2.getText();
jTextField3.setText(S1+S2);
2.Perform a Simple arithmetic operation(+,-,*,/) and display the result in Message Dialog.
1
//code for Add button
double a,b,result;
a=Double.parseDouble(jTextField1.getText());
b=Double.parseDouble(jTextField2.getText());
result=a+b;
JOptionPane.showMessageDialog(this, Addition of two numbers is:"+result);
3.Design a GUI application.The Customer is given a discount on the Bill Amount depending upon the Customer Type
selected from the combo box.Discount is calculated as follows:
Customer Type Discount
Paltinum 30%
Gold 20%
Silver 10%
New Customer NoDiscount
2
//code for discount
double finalamount=0;
double billamount=Double.parseDouble(jTextField1.getText());
switch(jComboBox1.getSelectedIndex())
{
case 0 : finalamount=0.70*billamount;break;
case 1 : finalamount=0.80*billamount;break;
case 2 : finalamount=0.90*billamount;break;
default:finalamount=billamount;
}
jTextField2.setText(Double.toString(finalamount));
4.Create a GUI application to perform both arithmetic and logical operation together(Example-Total,Average and
Grade calculation for given Marks)
3
//code for total
double total = 0,cs,e,gk,avg;
cs=Double.parsedouble(jTextField1.getText());
e= Double.parsedouble (jTextField2.getText());
total=cs+e+gk;
jTextField4.setText(Double.toString(total)); }
//code for Avg
int total,avg;
total= Double.parsedouble (jTextField4.getText());
avg=total/3;
jTextField5.setText(Double.toString(avg));
if(avg>=75)
jTextField6.setText("B");
else
if(avg>=60)
4
jTextField6.setText("c");
else
if (avg>=50)
jTextField6.setText("D");
else
jTextField6.setText("E");
5.Create a GUI applicatiomn to perform an operation based on the criteria input by the user in a CheckBox or a
RadioButton:
EX:-An electronic Shop has announced the following seasonal discounts on the purchase of certain items:
Purchase Amount In Rs Discount on TV Discount Music System
0-25000 5% 10%
25001-50000 10% 20%
More than 50000 15% 30%
Develop an application based on the above criteria,to input amount of purchase and the type of purchase(TV or Music
System using Jradio Button) by a customer.
Compute and print the net amount to be paid by a customer along with his name accepted in a text field.
[Hint: Discount=(Discount rate/100)*Amount of purchase
Net amount=amount of purchase-discount).]
5
//code for Calculate Button
double amt,total=0;
String n;
int d=0;
n=jTextField1.getText();
amt=Double.parseDouble(jTextField2.getText());
if(jRadioButton1.isSelected())
{
if(amt>+0 && amt<=25000)
d=5;
else if(amt>25001 && amt<=50000)
d=10;
else
d=15;
}
else if(jRadioButton2.isSelected())
{
if(amt>0 && amt<=25000)
d=10;
else if(amt>25001 && amt<=50000)
d=20;
else
d=30;
}
else JOptionPane.showMessageDialog(this,"Please select any one RadioButton");
if(jCheckBox1.isSelected())
d=d+5;
total=amt-amt*d/100;
jTextArea1.append("name :"+n);
jTextArea1.append("\nAmount :"+amt);
jTextArea1.append("\nTotal :"+total);
while (n!=0)
{
r=n%10;
sum=sum*10+r;
n=n/10;
}
jLabel2.setText("reverse of"+x+"is");
jTextField2.setText(" "+sum);
7.Desgin an GUI application for using Multiple Check Boxes and Combo Box,The sports and there charges are shown
in the following table:-
Sport name Charges
Foot Ball 2500
Cricket 3000
Table Tennis 3500
{
city="MUMBAI";
}
if(jComboBox1.getSelectedIndex()==2)
{
city="CHENNAI";
}
jTextArea1.append("CUSTOMER NAME:"+n);
jTextArea1.append("\nCUSTOMER PHONENO: "+pno);
jTextArea1.append("\nTOTAL CHARGES: "+a);
jTextArea1.append("\nCITY: "+city);
}
8.Develop an application to check whether a given year is Leap year or not. Leap
year are those years which are not exactly divisible by 100 and exactly divisible by
400 or exactly divisible by 4 only.
Int year=Integer.parseInt(jTextField1.getText());
8
jTextField2.setText(year+is a leap Year);
else
System.exit(0);
Int n=Integer.parseInt(jTextField1.getText());
Int I,j;
String str=;
for(i=1;i<=10;i++)
{ j=n*I;
str=str+j+ ; }
jTextField2.setText((i);
10. Develop a Login screen as given below. A Message dialog with relevant
message is appears as per given valid or invalid password .The valid password is
abcd.
9
//code for Login
String s1=jTextField1.getText();
String s2=jPasswordField1.getText();
if(s2.equals("abcd"))
JOptionPane.showMessageDialog(this, "U HAVE LOGGED SUCCESSFUL");
else
JOptionPane.showMessageDialog(this, "IN VAILED PASSWORD");
11.To display the given text in selected color using List control.
String c;
String t=jTextField1.getText();
If(jList1.isSelectedIndex(0)==true)
10
c=RED;
jTextField3.setForeground(Color.RED); }
if(jList1.isSelectedIndex(1)==true)
{ c="GREEN";
jTextField3.setForeground(Color.GREEN)
}if(jList1.isSelectedIndex(2)==true)
{ c="BLUE";
jTextField3.setForeground(Color.BLUE); }
if(jList1.isSelectedIndex(3)==true)
c="ORANGE";
jTextField3.setForeground(Color.ORANGE); }
jTextField2.setText(c);
jTextField3.setText(t);
11
Consider the Empl table and write SQL command to get the following.
1.Create the employee table with columns as shown in the above table.
4.Write a query to display EName and Sal of employee whose salary are greater than or
equal to 2200?
5.Write a query to display details of employee who are not getting commission?
6.Write a query to display employee name and salary of those employee who dont have
their salary in range of 2500 to 4000?
7.Write a query to display the name of employee whose name contains M as First and L as
third alphabet?
9.Write a query to display the details of employee whose dayname of hiredate is tuesday.
11.Displays the salary truncated to integer value(no decimal digits) of all the items.
1. Create the products table with column as shown in the above table .
2. Display the names of all the products in the store.
3. Display the names and unit price of all the products in the store
4. Display the names of all the products with unit price less than Rs.20000.00
5. Display the names of all the products whose names is not null.
6. Display all rows sorted in descending order of unit price.
7. Add one more column name as Quantity of the products table.
8. Change the Unit Price data of all the rows by applying a 10% discount
reduction on all the products.
12
9. Display details of all products with manufacturer name starting with "A"
10. Display the names and unitprice of all products whose unitprice is lessthan 22000 and manufactures is Fitness.
11. Display the all products who name has 4 letters.
12. Display names of all products that were purchased on Mondays or Tuesdays .
14. Create the following table named "Charity" and write SQL queries for the tasks
that follow:
Table: Charity
13
II. INSERT INTO EMPLOYEE VALUES(8845,XXXXX,SALESMAN,8699,1991-11-22,1600,NULL,30);
III. UPDATE EMPLOYEE SET WHERE JOB=MARKETING WHERE JOB=SALESMAN;
IV.SELECT ENAME,SAL FROM EMPLOYEE WHERE SAL>=2200;
V. SELECT *FROM EMPLOYEE WHERE COMM IS NULL;
VI. SELECT ENAME,SAL FROM EMPLOYEE WHERE SAL NOT BETWEEN 2500 AND 4000;
VII.SELECT ENAME FROM EMPLOYEE WHERE ENAME LIKE M__L%;
VIII.SELECT ENAME FROM EMPLOYEE where LENGTH(ename)=5;
IX. SELECT *FROM EMPOLYEE WHERE DAYNAME(HIREDATE)=TUESDAY;
X. UPDATE EMPLOYEE SET SAL=SAL+10 WHERE SAL<2000;
XI.SELECT SAL,TRUNCAT(SAL,0) FROM EMPLOYEE;
12.I. CREATE TABLE PRODUCT(PRCODE VARCHAR(10),PNAME VARCHAR(20),UNITPRICE INT,MANUFACTURE
VARCHAR(20),DATE_PURCHASE DATE);
II.SELECT PNAME FROM PRODUCTS;
III.SELECT PNAME,UNITPRICE FROM PRODEUCT;
IV.SELECT PNAME FROM PRODUCT WHERE UNITPRICE<20000;
V.SELECT PNAME FROM PRODUCTS WHERE PNAME IS NOT NULL;
VI.SELECT *FROM PRODUCTS ORDER BY UNITPRICE DESC;
VII.ALTER TABLE PRODUCTS ADD QUANTITY INT;
VIII.UPDATE PRODUCT SET UNITPRICE=UNITPRICE-UNITPRICE*10;
IX.SELECT *FROM PRODUCTS WHERE MANUFACTURER LIKEA%;
X.SELECT PNAME,UNITPRICE FROM PRODUCTS WHERE UNITPRICES<22000 && MANUFACTURER=FITNESS;
XI.SELECT *FROM PRODUCTS WHERE PNAME LIKE____;
XII.SELECT PNAME FROM PRODUCTS WHERE DAYNAME(DATE_PURCHASES)=MONDAY OR
DAYNAME(DATE_PURCHASES)=TUESDAY;
14