@@ -0,0 +1,2442 @@
+/*%0AThis program is aimed to teach a simple calculator program in Java.%0AGiven:%0ATwo labels to enter numbers. Two text fields to accept numbers%0AOne button for operation. One text field for the output/result.%0A%0AAssignment:%0A1. Modify the code such that the answer appears in the result text box%0A2. Add a different operation. Like subtraction, multiplication, division etc.%0A2.1 Add more buttons and text fields. Hint: you need to change the grid layout%0A*/%0A%0Aimport javax.swing.*;%0Aimport java.awt.GridLayout;%0Aimport java.awt.event.ActionEvent;%0Aimport java.awt.event.ActionListener;%0A%0Aclass Calculator implements ActionListener%7B%0A%09JLabel enterNumber1;%0A%09JTextField number1;%0A%09%0A%09JLabel enterNumber2;%0A%09JTextField number2; %0A%09%0A%09JButton operation;%0A%09JTextField result;%0A%09%0A%09public void actionPerformed(ActionEvent ae) %7B%0A%09%09int num1 = Integer.parseInt(number1.getText());%0A%09%09int num2 = Integer.parseInt(number2.getText());%0A%09%09%0A%09%09operation.setText(Integer.toString(num1 + num2));%0A%09%7D%0A%09%0A%09public JLabel getLabel1() %7Breturn enterNumber1;%7D%0A%09public JLabel getLabel2() %7Breturn enterNumber2;%7D%0A%09public JTextField getTextField1() %7Breturn number1;%7D%0A%09public JTextField getTextField2() %7Breturn number2;%7D%0A%09public JTextField getTextField3() %7Breturn result;%7D%0A%09public JButton getButton() %7Breturn operation;%7D%0A%09%0A%09public Calculator()%7B%0A%09%09enterNumber1 = new JLabel(%22Enter 1st number :%22);%0A%09%09number1 = new JTextField();%0A%09%09enterNumber2 = new JLabel(%22Enter 2nd number :%22);%0A%09%09number2 = new JTextField();%0A%09%09operation = new JButton(%22+%22);%0A%09%09result = new JTextField();%0A%09%7D%0A%0A%7D%0A%0Apublic class Compute %7B%0A%09public static void main(String s%5B%5D) %7B%0A%09%09JFrame window = new JFrame(%22Simple Calculator%22);%0A%09%09%0A%09%09// Default layout for the JFrame is BorderLayout with default position CENTER%0A%09%09window.setLayout(new GridLayout(3,2));%0A%09%09window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);%0A%09%0A%09%09%0A%09%09Calculator myCalculator = new Calculator();%0A%09%09%0A%09%09JLabel enterNumber1 = myCalculator.getLabel1();%0A%09%09JTextField number1 = myCalculator.getTextField1();%0A%09%09JLabel enterNumber2 = myCalculator.getLabel2();%0A%09%09JTextField number2 = myCalculator.getTextField2();%0A%09%09JButton operation = myCalculator.getButton();%0A%09%09JTextField result = myCalculator.getTextField3();%0A%09%09%0A%09%09operation.addActionListener(myCalculator);%0A%09%09%0A%09    window.add(enterNumber1);%0A%09    window.add(number1);%0A%09    window.add(enterNumber2);%0A%09    window.add(number2);%0A%09    window.add(operation);%0A%09    window.add(result);%0A%09%09%0A%09%09window.pack();%0A%09%09window.setVisible(true);%0A%09%7D%0A%7D%0A

Create Compute.java