├── cycle_5 ├── Screenshot from 2024-05-08 16-06-33.png ├── Screenshot from 2024-05-08 16-12-54.png ├── Screenshot from 2024-05-08 16-12-56.png ├── Screenshot from 2024-05-08 16-12-58.png ├── Screenshot from 2024-05-08 16-13-01.png ├── shapes.java ├── click_count.java └── calculator.java ├── cycle_4 ├── pr_2 │ ├── arithmatic │ │ ├── Div.java │ │ ├── Sum.java │ │ ├── Mul.java │ │ └── Sub.java │ └── calc.java └── pr_1 │ ├── graphics │ └── figures │ │ ├── Square.java │ │ ├── Circle.java │ │ ├── Rectangle.java │ │ └── Triangle.java │ └── Area.java ├── cycle_2 ├── StringSort.java ├── Search.java ├── Manipulate.java └── Employee.java ├── cycle_1 ├── main3.java ├── CPU.java ├── main2.java ├── main1.java └── main4.java └── cycle_3 ├── shapes.java ├── Score.java ├── teachers.java ├── BookDetails.java ├── calculator.java └── teacher2.java /cycle_5/Screenshot from 2024-05-08 16-06-33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerryjames2001/Java/HEAD/cycle_5/Screenshot from 2024-05-08 16-06-33.png -------------------------------------------------------------------------------- /cycle_5/Screenshot from 2024-05-08 16-12-54.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerryjames2001/Java/HEAD/cycle_5/Screenshot from 2024-05-08 16-12-54.png -------------------------------------------------------------------------------- /cycle_5/Screenshot from 2024-05-08 16-12-56.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerryjames2001/Java/HEAD/cycle_5/Screenshot from 2024-05-08 16-12-56.png -------------------------------------------------------------------------------- /cycle_5/Screenshot from 2024-05-08 16-12-58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerryjames2001/Java/HEAD/cycle_5/Screenshot from 2024-05-08 16-12-58.png -------------------------------------------------------------------------------- /cycle_5/Screenshot from 2024-05-08 16-13-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerryjames2001/Java/HEAD/cycle_5/Screenshot from 2024-05-08 16-13-01.png -------------------------------------------------------------------------------- /cycle_4/pr_2/arithmatic/Div.java: -------------------------------------------------------------------------------- 1 | package cycle_4.pr_2.arithmatic; 2 | public class Div { 3 | public void output(double x,double y) 4 | { 5 | System.out.println("\nDivision:"); 6 | System.out.println(x+" / "+y+"= "+(x/y)); 7 | } 8 | } -------------------------------------------------------------------------------- /cycle_4/pr_2/arithmatic/Sum.java: -------------------------------------------------------------------------------- 1 | package cycle_4.pr_2.arithmatic; 2 | public class Sum { 3 | public void output(double x,double y) 4 | { 5 | System.out.println("\nAddition:"); 6 | System.out.println(x+" + "+y+"= "+(x+y)); 7 | } 8 | } -------------------------------------------------------------------------------- /cycle_4/pr_2/arithmatic/Mul.java: -------------------------------------------------------------------------------- 1 | package cycle_4.pr_2.arithmatic; 2 | public class Mul { 3 | public void output(double x,double y) 4 | { 5 | System.out.println("\nMultiplication:"); 6 | System.out.println(x+" * "+y+"= "+(x*y)); 7 | } 8 | } -------------------------------------------------------------------------------- /cycle_4/pr_2/arithmatic/Sub.java: -------------------------------------------------------------------------------- 1 | package cycle_4.pr_2.arithmatic; 2 | public class Sub { 3 | public void output(double x,double y) 4 | { 5 | System.out.println("\nSubtraction:"); 6 | System.out.println(x+" - "+y+"= "+(x-y)); 7 | } 8 | } -------------------------------------------------------------------------------- /cycle_4/pr_1/graphics/figures/Square.java: -------------------------------------------------------------------------------- 1 | package graphics.figures; 2 | public class Square{ 3 | float l; 4 | double area; 5 | public void Square(float l) 6 | { 7 | this.l=l; 8 | area=l*l; 9 | } 10 | public void area() 11 | { 12 | System.out.println("Area of square="+area); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /cycle_4/pr_1/graphics/figures/Circle.java: -------------------------------------------------------------------------------- 1 | package graphics.figures; 2 | public class Circle{ 3 | float r; 4 | double area; 5 | double pi=3.14; 6 | public void Circle(float r) 7 | { 8 | this.r=r; 9 | area=pi*r*r; 10 | } 11 | public void area() 12 | { 13 | System.out.println("Area of circle="+area); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /cycle_4/pr_1/graphics/figures/Rectangle.java: -------------------------------------------------------------------------------- 1 | package graphics.figures; 2 | public class Rectangle{ 3 | float x; 4 | float y; 5 | double area; 6 | public void Rectangle(float a,float b) 7 | { 8 | this.x=a; 9 | this.y=b; 10 | area=x*y; 11 | } 12 | public void area() 13 | { 14 | System.out.println("Area of rectangle="+area); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /cycle_4/pr_1/graphics/figures/Triangle.java: -------------------------------------------------------------------------------- 1 | package graphics.figures; 2 | public class Triangle{ 3 | float l; 4 | float b; 5 | double area; 6 | public void Triangle(float l,float b) 7 | { 8 | this.l=l; 9 | this.b=b; 10 | area=0.5*l*b; 11 | } 12 | public void area() 13 | { 14 | System.out.println("Area of triangle="+area); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /cycle_5/shapes.java: -------------------------------------------------------------------------------- 1 | import java.awt.Color; 2 | import java.awt.Graphics; 3 | import javax.swing.JApplet; 4 | public class shapes extends JApplet { 5 | @Override 6 | public void paint(Graphics g){ 7 | setSize(500,500); 8 | g.drawLine(50,50,100,50); 9 | g.setColor(Color.LIGHT_GRAY); 10 | g.fillRect(50, 70, 60, 60); 11 | g.setColor(Color.green); 12 | g.fillOval(50, 150, 70, 70); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /cycle_4/pr_1/Area.java: -------------------------------------------------------------------------------- 1 | import graphics.figures.*; 2 | import java.util.Scanner; 3 | public class Area{ 4 | 5 | public static void main(String[] args) 6 | { 7 | System.out.println("Jerry James \n 23mca036 \n 10-04-24"); 8 | System.out.println("Package using shapes"); 9 | System.out.println("****************************"); 10 | Rectangle r=new Rectangle(); 11 | Circle c=new Circle(); 12 | Triangle t=new Triangle(); 13 | Square s=new Square(); 14 | r.Rectangle(5,2); 15 | r.area(); 16 | c.Circle(2); 17 | c.area(); 18 | t.Triangle(2,3); 19 | t.area(); 20 | s.Square(5); 21 | s.area(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cycle_4/pr_2/calc.java: -------------------------------------------------------------------------------- 1 | package cycle_4.pr_2; 2 | 3 | import cycle_4.pr_2.arithmatic.*; 4 | import java.util.*; 5 | 6 | class calc { 7 | public static void main(String[] args) 8 | { 9 | Div d=new Div(); 10 | Mul m=new Mul(); 11 | Sub sub=new Sub(); 12 | Sum s=new Sum(); 13 | double a,b; 14 | Scanner sc=new Scanner(System.in); 15 | System.out.print("\nEnter 2 numbers: "); 16 | a=sc.nextInt(); 17 | b=sc.nextInt(); 18 | s.output(a, b); 19 | sub.output(a, b); 20 | d.output(a, b); 21 | m.output(a, b); 22 | sc.close(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /cycle_2/StringSort.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | import java.util.Arrays; 3 | class StringSort{ 4 | void input() 5 | { 6 | try(Scanner sc=new Scanner(System.in)) 7 | { 8 | System.out.println("Enter the string"); 9 | String st=sc.nextLine(); 10 | char array[]=st.toCharArray(); 11 | Arrays.sort(array); 12 | System.out.println("After sorting"); 13 | st=new String(array); 14 | System.out.println("Character is : "+st); 15 | } 16 | } 17 | 18 | 19 | public static void main(String[] args) 20 | { 21 | System.out.println("Jerry James\n23mca036\n26-02-2024"); 22 | System.out.println("Program to Sort strings"); 23 | System.out.println("***************************\n"); 24 | StringSort obj=new StringSort(); 25 | obj.input(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /cycle_1/main3.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class main3 { 3 | int img,real; 4 | void input(Scanner sc) 5 | { 6 | System.out.println("Enter the real part "); 7 | real=sc.nextInt(); 8 | System.out.println("Enter the imaginary part "); 9 | img=sc.nextInt(); 10 | } 11 | 12 | 13 | public static void main(String[] args) { 14 | System.out.println("Jerry James \n 23mca036 \n 19-02-24"); 15 | System.out.println("Add complex numbers"); 16 | System.out.println("****************************"); 17 | try(Scanner sc=new Scanner(System.in)) 18 | { 19 | main3 one=new main3(); 20 | main3 two=new main3(); 21 | one.input(sc); 22 | two.input(sc); 23 | int simg = one.img + two.img; 24 | int sreal = one.real + two.real; 25 | System.out.println("\n"+sreal+" + "+simg+"i"); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /cycle_2/Search.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | class Search{ 3 | 4 | void input() 5 | { 6 | try(Scanner sc=new Scanner(System.in)) 7 | { 8 | int[] ar=new int[10]; 9 | int n,key,i,x=0,flag=0; 10 | System.out.println("Enter the limit for elements"); 11 | n=sc.nextInt(); 12 | System.out.println("Enter the elements"); 13 | for(i=0;i 10 | private void initComponents() { 11 | 12 | display = new java.awt.Label(); 13 | clickk = new java.awt.Button(); 14 | 15 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 16 | 17 | display.setText("count:"); 18 | 19 | clickk.setLabel("Click"); 20 | clickk.addActionListener(new java.awt.event.ActionListener() { 21 | public void actionPerformed(java.awt.event.ActionEvent evt) { 22 | clickkActionPerformed(evt); 23 | } 24 | }); 25 | 26 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 27 | getContentPane().setLayout(layout); 28 | layout.setHorizontalGroup( 29 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 30 | .addGroup(layout.createSequentialGroup() 31 | .addGap(134, 134, 134) 32 | .addComponent(display, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE) 33 | .addGap(45, 45, 45) 34 | .addComponent(clickk, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 35 | .addContainerGap(117, Short.MAX_VALUE)) 36 | ); 37 | layout.setVerticalGroup( 38 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 39 | .addGroup(layout.createSequentialGroup() 40 | .addGap(86, 86, 86) 41 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 42 | .addComponent(clickk, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 43 | .addComponent(display, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 44 | .addContainerGap(190, Short.MAX_VALUE)) 45 | ); 46 | 47 | pack(); 48 | }// 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | int i=0,r=0,gr=10,b=100; 59 | private void clickkActionPerformed(java.awt.event.ActionEvent evt) { 60 | i++; 61 | Color newColor=new Color(r,gr,b); 62 | getContentPane().setBackground(newColor); 63 | r=(r+10)%256; 64 | gr=(gr+10)%256; 65 | b=(b+10)%256; 66 | repaint(); 67 | display.setText("Count:"+String.valueOf(i)); 68 | // TODO add your handling code here: 69 | } 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | /** 82 | * @param args the command line arguments 83 | */ 84 | public static void main(String args[]) { 85 | try { 86 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { 87 | if ("Nimbus".equals(info.getName())) { 88 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); 89 | break; 90 | } 91 | } 92 | } catch (ClassNotFoundException ex) { 93 | java.util.logging.Logger.getLogger(click_count.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 94 | } catch (InstantiationException ex) { 95 | java.util.logging.Logger.getLogger(click_count.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 96 | } catch (IllegalAccessException ex) { 97 | java.util.logging.Logger.getLogger(click_count.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 98 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { 99 | java.util.logging.Logger.getLogger(click_count.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 100 | } 101 | // 102 | 103 | /* Create and display the form */ 104 | java.awt.EventQueue.invokeLater(new Runnable() { 105 | public void run() { 106 | new click_count().setVisible(true); 107 | } 108 | }); 109 | } 110 | // Variables declaration - do not modify 111 | private java.awt.Button clickk; 112 | private java.awt.Label display; 113 | // End of variables declaration 114 | } 115 | -------------------------------------------------------------------------------- /cycle_5/calculator.java: -------------------------------------------------------------------------------- 1 | public class summm extends javax.swing.JFrame { 2 | public summm() { 3 | initComponents(); 4 | } 5 | 6 | @SuppressWarnings("unchecked") 7 | // 8 | private void initComponents() { 9 | 10 | input1 = new java.awt.TextField(); 11 | input2 = new java.awt.TextField(); 12 | output = new java.awt.TextField(); 13 | sum = new java.awt.Button(); 14 | label1 = new java.awt.Label(); 15 | label2 = new java.awt.Label(); 16 | label3 = new java.awt.Label(); 17 | sub = new java.awt.Button(); 18 | mul = new java.awt.Button(); 19 | div = new java.awt.Button(); 20 | 21 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 22 | 23 | input1.addActionListener(new java.awt.event.ActionListener() { 24 | public void actionPerformed(java.awt.event.ActionEvent evt) { 25 | input1ActionPerformed(evt); 26 | } 27 | }); 28 | 29 | input2.addActionListener(new java.awt.event.ActionListener() { 30 | public void actionPerformed(java.awt.event.ActionEvent evt) { 31 | input2ActionPerformed(evt); 32 | } 33 | }); 34 | 35 | output.addActionListener(new java.awt.event.ActionListener() { 36 | public void actionPerformed(java.awt.event.ActionEvent evt) { 37 | outputActionPerformed(evt); 38 | } 39 | }); 40 | 41 | sum.setLabel("+"); 42 | sum.setName(""); // NOI18N 43 | sum.addActionListener(new java.awt.event.ActionListener() { 44 | public void actionPerformed(java.awt.event.ActionEvent evt) { 45 | sumActionPerformed(evt); 46 | } 47 | }); 48 | 49 | label1.setText("Enter num"); 50 | 51 | label2.setText("Enter num"); 52 | 53 | label3.setText("Answer:"); 54 | 55 | sub.setLabel("-"); 56 | sub.setName(""); // NOI18N 57 | sub.addActionListener(new java.awt.event.ActionListener() { 58 | public void actionPerformed(java.awt.event.ActionEvent evt) { 59 | subActionPerformed(evt); 60 | } 61 | }); 62 | 63 | mul.setLabel("*"); 64 | mul.setName(""); // NOI18N 65 | mul.addActionListener(new java.awt.event.ActionListener() { 66 | public void actionPerformed(java.awt.event.ActionEvent evt) { 67 | mulActionPerformed(evt); 68 | } 69 | }); 70 | 71 | div.setLabel("/"); 72 | div.setName(""); // NOI18N 73 | div.addActionListener(new java.awt.event.ActionListener() { 74 | public void actionPerformed(java.awt.event.ActionEvent evt) { 75 | divActionPerformed(evt); 76 | } 77 | }); 78 | 79 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 80 | getContentPane().setLayout(layout); 81 | layout.setHorizontalGroup( 82 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 83 | .addGroup(layout.createSequentialGroup() 84 | .addContainerGap() 85 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 86 | .addGroup(layout.createSequentialGroup() 87 | .addGap(46, 46, 46) 88 | .addComponent(sum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 89 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 90 | .addComponent(sub, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 91 | .addGroup(layout.createSequentialGroup() 92 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 93 | .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 94 | .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)) 95 | .addGap(47, 47, 47) 96 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 97 | .addGroup(layout.createSequentialGroup() 98 | .addComponent(mul, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 99 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 100 | .addComponent(div, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 101 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) 102 | .addComponent(input2, javax.swing.GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE) 103 | .addComponent(input1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 104 | .addGroup(layout.createSequentialGroup() 105 | .addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 106 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 107 | .addComponent(output, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))))) 108 | .addContainerGap(138, Short.MAX_VALUE)) 109 | ); 110 | layout.setVerticalGroup( 111 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 112 | .addGroup(layout.createSequentialGroup() 113 | .addGap(27, 27, 27) 114 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 115 | .addComponent(input1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 116 | .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 117 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 118 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 119 | .addComponent(input2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 120 | .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 121 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 122 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 123 | .addComponent(sum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 124 | .addComponent(sub, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 125 | .addComponent(mul, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 126 | .addComponent(div, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 127 | .addGap(42, 42, 42) 128 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 129 | .addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 130 | .addComponent(output, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 131 | .addContainerGap(131, Short.MAX_VALUE)) 132 | ); 133 | 134 | sum.getAccessibleContext().setAccessibleName("+"); 135 | 136 | pack(); 137 | }// 138 | 139 | private void input1ActionPerformed(java.awt.event.ActionEvent evt) { 140 | } 141 | 142 | private void outputActionPerformed(java.awt.event.ActionEvent evt) { 143 | output.setEditable(false); 144 | } 145 | 146 | private void sumActionPerformed(java.awt.event.ActionEvent evt) { 147 | String snum1 = input1.getText(); 148 | String snum2 = input2.getText(); 149 | try { 150 | int num1 = Integer.parseInt(snum1); 151 | int num2 = Integer.parseInt(snum2); 152 | int sum = num1 + num2; 153 | output.setText(String.valueOf(sum)); 154 | } catch (NumberFormatException ex) { 155 | output.setText("Invalid input"); 156 | } 157 | } 158 | 159 | private void input2ActionPerformed(java.awt.event.ActionEvent evt) { 160 | } 161 | 162 | private void subActionPerformed(java.awt.event.ActionEvent evt) { 163 | String snum1 = input1.getText(); 164 | String snum2 = input2.getText(); 165 | try { 166 | int num1 = Integer.parseInt(snum1); 167 | int num2 = Integer.parseInt(snum2); 168 | int sum = num1 - num2; 169 | output.setText(String.valueOf(sum)); 170 | } catch (NumberFormatException ex) { 171 | output.setText("Invalid input"); 172 | } 173 | } 174 | 175 | private void mulActionPerformed(java.awt.event.ActionEvent evt) { 176 | String snum1 = input1.getText(); 177 | String snum2 = input2.getText(); 178 | try { 179 | int num1 = Integer.parseInt(snum1); 180 | int num2 = Integer.parseInt(snum2); 181 | int sum = num1 * num2; 182 | output.setText(String.valueOf(sum)); 183 | } catch (NumberFormatException ex) { 184 | output.setText("Invalid input"); 185 | } 186 | } 187 | 188 | private void divActionPerformed(java.awt.event.ActionEvent evt) { 189 | String snum1 = input1.getText(); 190 | String snum2 = input2.getText(); 191 | try { 192 | int num1 = Integer.parseInt(snum1); 193 | int num2 = Integer.parseInt(snum2); 194 | int sum = num1 / num2; 195 | output.setText(String.valueOf(sum)); 196 | } catch (NumberFormatException ex) { 197 | output.setText("Invalid input"); 198 | } 199 | } 200 | 201 | public static void main(String args[]) { 202 | 203 | try { 204 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { 205 | if ("Nimbus".equals(info.getName())) { 206 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); 207 | break; 208 | } 209 | } 210 | } catch (ClassNotFoundException ex) { 211 | java.util.logging.Logger.getLogger(summm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 212 | } catch (InstantiationException ex) { 213 | java.util.logging.Logger.getLogger(summm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 214 | } catch (IllegalAccessException ex) { 215 | java.util.logging.Logger.getLogger(summm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 216 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { 217 | java.util.logging.Logger.getLogger(summm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 218 | } 219 | 220 | java.awt.EventQueue.invokeLater(new Runnable() { 221 | public void run() { 222 | new summm().setVisible(true); 223 | } 224 | }); 225 | } 226 | 227 | // Variables declaration - do not modify 228 | private java.awt.Button div; 229 | private java.awt.TextField input1; 230 | private java.awt.TextField input2; 231 | private java.awt.Label label1; 232 | private java.awt.Label label2; 233 | private java.awt.Label label3; 234 | private java.awt.Button mul; 235 | private java.awt.TextField output; 236 | private java.awt.Button sub; 237 | private java.awt.Button sum; 238 | // End of variables declaration 239 | } 240 | --------------------------------------------------------------------------------