@@ -33,11 +33,11 @@ public class UI implements ActionListener {
3333 private final JTextArea text ;
3434 private final JButton but [], butAdd , butMinus , butMultiply , butDivide ,
3535 butEqual , butCancel , butSquareRoot , butSquare , butOneDevidedBy ,
36- butCos , butSin , butTan , butxpowerofy , butlog , butrate ;
36+ butCos , butSin , butTan , butxpowerofy , butlog , butrate , butabs ;
3737 private final Calculator calc ;
3838
3939 private final String [] buttonValue = { "0" , "1" , "2" , "3" , "4" , "5" , "6" ,
40- "7" , "8" , "9" };
40+ "7" , "8" , "9" };
4141
4242 public UI () {
4343 frame = new JFrame ("Calculator PH" );
@@ -64,6 +64,7 @@ public UI() {
6464 butxpowerofy = new JButton ("x^y" );
6565 butlog = new JButton ("log10(x)" );
6666 butrate = new JButton ("x%" );
67+ butabs = new JButton ("abs(x)" );
6768
6869 butCancel = new JButton ("C" );
6970
@@ -98,6 +99,7 @@ public void init() {
9899 panel .add (butxpowerofy );
99100 panel .add (butlog );
100101 panel .add (butrate );
102+ panel .add (butabs );
101103
102104 panel .add (butEqual );
103105 panel .add (butCancel );
@@ -115,6 +117,7 @@ public void init() {
115117 butxpowerofy .addActionListener (this );
116118 butlog .addActionListener (this );
117119 butrate .addActionListener (this );
120+ butabs .addActionListener (this );
118121
119122 butEqual .addActionListener (this );
120123 butCancel .addActionListener (this );
@@ -190,6 +193,9 @@ public void actionPerformed(ActionEvent e) {
190193 writer (calc .calculateMono (Calculator .MonoOperatorModes .rate ,
191194 reader ()));
192195 }
196+ if (source == butabs ){
197+ writer (calc .calculateMono (Calculator .MonoOperatorModes .abs , reader ()));
198+ }
193199
194200 if (source == butEqual ) {
195201 writer (calc .calculateEqual (reader ()));
0 commit comments