Sunteți pe pagina 1din 20

INDEX

# Net Bean java


1. System.out.printimplementation……..
2. Data Form using textfield, label………
3. GUI of Discount calculator…….
4. Mathematical operation on gui……….
5. Simple interest og GUI………….
6. Greater of 3 numbers on GUI………….
7. For loop printing counting 10-2……….
8. For loop , sum of first 10 natural no. …………
9. GUI Score board on net bean java…………
10. Program import javax.swing.JoptionPane…….
11. Using LIST BOX, show list of states & capital of s……..
12. Using if condition show person eligible or not………
13.
1.public class Simple{
public static void main(String args[]){
System.out.println("Hello! I Am Sanjeet");
}}
Output
2.

private void
gbuttonActionPerformed(java.awt.event.ActionEventevt)
{
// TODO add your handling code here:
String t1=tf1.getText();
String t2=tf2.getText();
String t3=tf3.getText();
String t4=tf4.getText();
String t5=tf5.getText();
ta.append("Student Details"+"\n");
ta.append("name: "+t1+" "+t2+" "+t3+"\n");
ta.append("class: "+t4+"--"+t5+"");

}
Output
3.

private void
cbtnActionPerformed(java.awt.event.ActionEventevt) {
String t1=tf1.getText();
double price=Double.parseDouble(t1);
String t2=tf2.getText();
double quantity=Double.parseDouble(t1);

double t3=price*quantity;
double discount=t3*0.10;
double netamount=t3-discount;
tf3.setText(""+t3);
tf3.setText(""+discount);
tf3.setText(""+netamount);
}
Output
4. private void
btnAOActionPerformed(java.awt.event.ActionEventevt) {

int n1, n2, aoPlus, aoMult, aoRem, Diff;

float aoDiv;

n1 = Integer.parseInt(txtNum1.getText());

n2 = Integer.parseInt(txtNum2.getText());

aoPlus = n1 + n1; // integer addition

Diff = n1 - n2; // integer subtraction

aoMult = n1 * n2; // integer multiplication

aoDiv = n1 / n2; // integer division

aoRem = n1 % n2;

txtPlus.setText(“”+aoPlus );

txtMinus.setText(“”+ Diff);

txtMult.setText(“”+aoMult);

txtDiv.setText(“”+aoDiv);
txtMod.setText(“”+aoRem);

private void
btnExitActionPerformed(java.awt.event.ActionEventevt)
{

System.exit(0);

5.
private void
calculateinterestActionPerformed(java.awt.event.ActionEventevt) {
int prin = Integer.parseInt (t1.getText());
int rate = Integer.parseInt (t2.getText());
int time = Integer.parseInt (t3.getText());
double interest = ( prin * rate * time) / 100;
t4.setText ("" + interest);
}
private void
calculateamountActionPerformed(java.awt.event.ActionEventevt) {
int prin = Integer.parseInt (t1.getText());
int rate = Integer.parseInt (t2.getText());
int time = Integer.parseInt (t3.getText());
double interest = ( prin * rate * time) / 100;
double amount = prin + interest;
t5.setText ("" + amount);
}
private void exitActionPerformed(java.awt.event.ActionEventevt) {
System.exit(0);
}
private void clearActionPerformed(java.awt.event.ActionEventevt) {
t1.setText("");
t2.setText("");
t3.setText("");
t4.setText("");
t5.setText(""); }

6.
private void grButtonActionPerformed(java.awt.event.ActionEventevt) {
int N1, N2, N3;
int max;
N1 = Integer.parseInt(txtN1.getText());
N2 = Integer.parseInt(txtN2.getText());
N3 = Integer.parseInt(txtN3.getText());
if ((N1 > =N2) && (N1 > N3))
max = N1;
else if ((N2 > =N1) && (N2 > N3))
max = N2;
else if ((N3 > N1) && (N3 > N2))
max = N3;
jLabel4.setText("The greater number is : " + max)
}
private void exButtonActionPerformed(java.awt.event.ActionEventevt) {
System.exit(0);
}

7. for(int i=10; i>1; i--)


{
System.out.println("The value of i is: "+i);
}
Output

8.int num = 10, count, total = 0;


for(count = 1; count <= num; count++){
total = total + count;
}
System.out.println("Sum of first 10 natural numbers is:
"+total);
}
Output
9.

.
private void
goalofaActionPerformed(java.awt.event.ActionEvent
evt) {
String v1=tf1.getText();
int ga=Integer.parseInt(v1);
ga = ga+1;
tf1.setText(""+ga);
}

private void
goalofbActionPerformed(java.awt.event.ActionEvent
evt) {
String v1=tf2.getText();
int gb=Integer.parseInt(v1);
gb = gb+1;
tf2.setText(""+gb); }
private void
rbtnActionPerformed(java.awt.event.ActionEventevt
){
String v1=tf1.getText();
int ga=Integer.parseInt(v1);
String v2=tf2.getText();
int gb=Integer.parseInt(v2);
String res =(ga>gb?"Team A Wins" :
(ga<gb)?"Team B Wins" : "Draws");
ta1.setText(res);

Output
10.

import javax.swing.JOptionPane;

public class SimpleInputDialog1 {

public static void main(String[] args){

String m =
JOptionPane.showInputDialog("Anyone there?");
System.out.println(m);
}}

Outout
11.

private void l1ValueChanged(javax.swing.event.ListSelectionEvent evt) {


int i = l1.getSelectedIndex ();
String name = null;
switch (i)
{
case 0 : name = (" Hyderabad ");
break;
case 1 : name = (" Itanagar ");
break;
case 2 : name = ( " Dispur ");
break;
case 3 : name = ( " Patna ");
break;
case 4 : name = (" Raipur ");
break;
case 5 : name = (" Panaji");
break;
case 6 : name = (" Ahmedabad ");
break;
case 7 : name = (" Chandigarh ");
break;
case 8 : name = (" Shimla ");
break;
case 9 : name = (" Srinagar");
break;
case 10 : name = (" Ranchi");
break;
case 11 : name = (" Bangalore");
break;
case 12 : name = (" Thiruvananthapuram ");
break;
case 13 : name = (" Bhopal");
break;
case 14 : name = (" Mumbai");
break;
case 15 : name = (" Imphal");
break;
case 16 : name = (" Shillong");
break;
case 17 : name = (" Aizawl");
break;
case 18 : name = (" Kohima");
break;
case 19 : name = (" Bhubaneshwar");
break;
case 20 : name = (" Chandigarh");
break;
case 21 : name = (" Jaipur");
break;
case 22 : name = (" Gangtok");
break;
case 23 : name = (" Chennai");
break;
case 24 : name = (" Agartala");
break;
case 25 : name = (" Lucknow");
break;
case 26 : name = (" Dehradun");
break;
case 27 : name = (" Kolkata");
break;
default: name = null;
}
t1.setText(" " + name);
}
12.

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


{
int age;
String txt=tf1.getText();
age=Integer.parseInt(txt);
if(age>=18)
msglabel.setText("You are eligible voter");
if(age<18)
msglabel.setText("You are not eligible for voting ");
}
Output

S-ar putea să vă placă și