Vous êtes sur la page 1sur 28

Q.Mr.Rouble freqently needs to calculate interest and amount due for his clients.

He asked
his software programmer to design an interest calculator which the compund interest and
amount due if he takes a loan for 5,10,15 years.

Calculate Interest:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
int T=0;
double CI=0,Amount=0;
double P=Double.parseDouble(txtPrincipal.getText());
float R=Float.parseFloat(txtRate.getText());
if(Opt5.isSelected())
T=5;
else
if(Opt10.isSelected())
T=10;
else
if(Opt15.isSelected())
T=15;
//pow()function calculates power of a number
CI=P*Math.pow((1+(R/100)),T);
Amount=P+CI;
txtInterest.setText(String.valueOf(CI));
txtAmount.setText(String.valueOf(Amount);
}
Output:

Q.Write the code for Check Date Button to display where an input date is valid date or
not.Display:If the entered date is valid the message is: Valid date Otherwise the message
is:Invalid date.

Q.Design a GUI application(SumDiff)to input two numbers as in two text boxes(txtN1 and
txtN2)and find their sum and difference by choosing a checkBox from a panel using switch
statment.

Sum:
private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {
int N1,N2,sum=0;
N1=Integer.parseInt(txtN1.getText());
N2=Integer.parseInt(txtN2.getText());
sum=N1+N2;
jLabel3.setText("Sum is:"+sum);
}
Difference:
private void jCheckBox2ActionPerformed(java.awt.event.ActionEvent evt) {
int N1,N2,diff=0;
N1=Integer.parseInt(txtN1.getText());
N2=Integer.parseInt(txtN2.getText());
if(N1>N2)
diff=N1-N2;
else
diff=N2-N1;
jLabel3.setText("The diffrence between"+N1+"and"+N2+"is="+diff);
}
Output:
Sum:

Difference:

Q.Write the code for calculate Total , Percentage & Grade button also to display the same in
respective text boxes.

Calculate Total , Percentage & Grade:


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
int R,eng,acc,bst,inf,eco,tot;
float per;
String Name,Gr="";
R=Integer.parseInt(txtRoll.getText());
eng=Integer.parseInt(txtEng.getText());
acc=Integer.parseInt(txtAcc.getText());
bst=Integer.parseInt(txtBst.getText());
inf=Integer.parseInt(txtInf.getText());
eco=Integer.parseInt(txtEco.getText());
tot=eng+acc+bst+inf+eco;
per=tot/5;
if(per>=90)
Gr="A+";
else
if(per>=80&&per<90)
Gr="A";
else
if(per>=70&&per<80)
Gr="B";
else
if(per>=60&&per<70)
Gr="C";
else

if(per>=50&&per<60)
Gr="D";
else
if(per<50)
Gr="F";
txtTotal.setText(Integer.toString(tot));
txtPer.setText(Float.toString(per));
txtGr.setText(Gr);
}
Output:

Q.Design a GUI application in which the sum of digit of the number should be displayed in a
label control.

Sum of digit:

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


int num,value,sum=0,r_digit;
num=Integer.parseInt(txtnum.getText());
value = num;
while (num!=0){
r_digit=num%10;
sum=sum+r_digit;
num=num/10;
}
jLabel2.setText("Sum of digits:"+String.valueOf(sum));
Output:

Q.Write the command for discount button to compute discount amount and net amount.

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


double discount=0;
double netamount=0;
double Amount=Double.parseDouble(txtAmount.getText());
if (optHDFC.isSelected())
discount = Amount*12/100;
else if(optICICI.isSelected())
discount = Amount*10/100;
else if(optVISA.isSelected());
discount = Amount*9.5/100;
else if(optAxis.isSelected());
discount = Amount*10.5/100;
else if(optSC.isSelected());
discount = Amount*8.5/100;
else if(optCity.isSelected());
discount = Amount*11.5/100;
else if(optSBI.isSelected());
discount = Amount8*11.5/100;
netamount=Amount-discount;
txtDisc.setText(String.valueOf(discount));

txtNet.setText(String.valueOf(netamount));

Q.Design a GUI application to print the mathematical table from 1 to 5 in a JtextArea


control.

Calculate Table:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
int i,j,k;
for(i=1;i<=5;i++){
for(j=1;j<=10;j++){
k=i*j;txtTable.append(""+i+"*"+j+"="+k+"\n");
}
txtTable.append("-------------------\n");
}
Output:

Q.Write a programme to input a string a screen through keyboard and dispaly in reverse
order.

Reverse:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String str;
int value,r_digit;
value=0;
while(value<=0){
value=Integer.parseInt(txtNum.getText());
if(value<=0){
break;
}
}
str="";
while(value!=0){
r_digit=value%10;
str=str+Integer.toString(r_digit);
value=value/10;
}
txtRev.setText(str);
}
Output:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String str;
int value,r_digit;

value=0;
while(value<=0){
value=Integer.parseInt(txtNum.getText());
if(value<=0){
break;
}
Output:

QWrite the code for Calculate Rate button and Calculate Amount Button.

Calclate Rate:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
if(RB1.isSelected())

txtRate.setText(Integer.toString(1500));
if(RB2.isSelected())
txtRate.setText(Integer.toString(2800));
if(RB3.isSelected())
txtRate.setText(Integer.toString(5000));
Calculate Amount:
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
if(Chk1.isSelected())
txtFacility.setText(Integer.toString(7000));
if(Chk2.isSelected())
txtFacility.setText(Integer.toString(2000));
if(Chk3.isSelected())
txtFacility.setText(Integer.toString(1000));
Double.parseDouble(txtDays.getText());
Double.parseDouble(txtFacility.getText());
txtAmount.setText(Double.toString(TAmount));
Output:

Q.GREATER AMONG THREE.

(A) Write the command for greater button.

(B) Write the code for exit button.

Q.Write the code for Calculate button amount are computed and displayed.

Calculate:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
float subTot=0,charge=0,tax=0,Total=0;
int qty=Integer.parseInt(txtQty.getText());
float uPrice=Float.parseFloat(txtPrice.getText());
subTot=qty*uPrice;
tax=subTot*(float)6.5/100;
if(optA.isSelected())
charge=2000;
if(optB.isSelected())
charge=3000;
if(optC.isSelected())
charge=3500;
Total=subTot+tax+charge;
txtSub.setText(String.valueOf(subTot));
txtTax.setText(String.valueOf(tax));
txtCharge.setText(String.valueOf(charge));
txtTotal.setText(String.valueOf(Total));
Output:

Q.Design a GUI application to find out Armstrong numbers.

Find Armstrong:

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


int n,i,k,s=0,d;
String str;
str=("Enter the frist term=>");
n=Integer.parseInt(str);
for(i=2;i<=n;i++){
s=0;
k=i;
while(k!=0){
d=k%10;
s=s+d*d*d;
k=k/10;
}
if(s==i)
jLabel3.setText("Number is an armstrong number");
else
jLabel3.setText("Number is not an armstrong number");
}
Output:

Q.Design a GUI application to calculate the factorial of number.

Find Factorial:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
int num;

float fact=1;
String str=JOptionPane.showMessageDialog("Enter number to find Factorial");
txtNum.setText(str);
num=Integer.parseInt(str);
if(num<=1){
JOptionPane.showMessageDialog(this,"Factorial is 1");
}
do{
fact=fact*num;
num=num-1;
}
while(num>1);
txtFact.setText(Float.toString(fact));
} OUTPUT

Q.The bank provides three types of loan- car loan,house loan,education loan. Calculate
interest amount and discount amount.

show interest amount:


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
float IntAmt=0;
if (optcar.isSelected()){
IntAmt=Float.parseFloat(txtlamt.getText())*10/100;
txtamt.setText(String.valueOf(IntAmt));
}
else if(opthouse.isSelected()){
IntAmt=Float.parseFloat(txtlamt.getText())*(float)8.5/100;
txtamt.setText(String.valueOf(IntAmt));
}
else if(optedu.isSelected()){
IntAmt=Float.parseFloat(txtlamt.getText())*5/100;
txtamt.setText(String.valueOf(IntAmt));
}
}
calculate discount:
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
float intAmt=Float.parseFloat(txtamt.getText());
float discount=0,NetAmt=0;
float amount=Float.parseFloat(txtlamt.getText());
if(amount<=1000000)
discount=amount*(float)(0.20/100);
if(amount>1000000)
discount=amount*(float)(0.20/100);
NetAmt=intAmt-discount;
txtdisc.setText(String.valueOf(discount));
txtamt.setText(String.valueOf(NetAmt));
}
output

Q.Design a GUI application (dtob)to convert decimal number into binary number.

Decimal to binary:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String str,str1="";
int n,r,n1,r_digit,ln,i;
int[]ar;
ar=new int[10];
str=JOptionPane.showInputDialog("ENTER THE DECIMAL NUMBER");
n=Integer.parseInt(str);

n1=n;
str="";
i=0;
while(n!=0){
r=n%2;
n=n/2;
ar[i]=r;
i++;
}
i--;
//Printing the decimal into a decimal number into a text field.
txtd.setText(Integer.toString(n1));
//storing the array in reverse order as binary number
for(int j=i;j>=0;j--)
str1=str1+ar[j];
//printing the binary number
txtb.setText(str1);// TODO add your handling code here:
}
Q. Write code for button to display the list price,discount price and net price.

list price:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String Product=cmbProduct.getSelectedItem().toString();
if (Product.equals("washing machine")){
txtlprice.setText("12000");
}
else if (Product.equals("colour television")){
txtlprice.setText("17000");
}

else if (Product.equals("refrigerator")){
txtlprice.setText("18000");
}
else if (Product.equals("otg")){
txtlprice.setText("8000");
}
else if (Product.equals("cd player")){
txtlprice.setText("14500");
}
}
discount price:
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
Float ProductPrice,Discount;
ProductPrice=Float.parseFloat(txtlprice.getText());
if (optfest.isSelected()){
Discount = ProductPrice*7/100;
}
else {
Discount = ProductPrice*10/100;
}
txtdisc.setText(Float.toString(Discount));// TODO add your handling code here:
}
net price:
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
float NetPrice;
NetPrice=Float.parseFloat(txtlprice.getText())- Float.parseFloat(txtdisc.getText());
txtnprice.setText(Float.toString(NetPrice));// TODO add your handling code here:
}
output:

Q. Write code for to calculate rate button and calculate Amount and display it.

Calculate Rate:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
if(optregular.isSelected())
txtrate.setText(String.valueOf(220));
else if(optpan.isSelected())
txtrate.setText(String.valueOf(260));
Calculate Amount:
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
int top=0;
float Amt=0;
if(chkcheese.isSelected()){
top=40;
}
if(chkcapsicum.isSelected()){
top=top+20;

}
if(chkPepperonion.isSelected()){
top=top+25;
}
txttop.setText(Integer.toString(top));
Amt=(Integer.parseInt(txtrate.getText())+top)*Integer.parseInt(txtqty.getText());
txtamt.setText(Float.toString(Amt));
}

Q. DESIGN ABN Shipment Corporation

(A).Write code to disable text boxes and wholesaler as


default option when the form is active.

(B) Write the code to calculate cost button.

TABLE:- CLUB &COACHES

Q1.Identify the Primary Keys.


Answer. Coach_ID and Coach_no
Q2.What will be the output Select Sportsperson,Coach Name
From CLUB,COACHES WHERE COACH_ID=COACH_no

TABLE:- GRADUATE & GUIDE

Q1.Identify Primary keys from Graduate and


Guide.
Answer. SNO and MAINAREA
Q2.What will be the output
Select Name,Adviser from Graduate,Guide where
Subject=MAINAREA;

Vous aimerez peut-être aussi