0

I want to implement more Advance features to my java simple Calculator

I build a simple calculator using java and now i want to add more advance features where i will be able to add more operands and operators at a time.. like my own simple calculator is to handle two numbers at once like 2+2=4 but i want something more sophisticated like unlimited operands and different operators too like 2+6*5/2= ? in one line.. Please help me out!! ***This is my former code:*** import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.awt.Font; import java.awt.font.*; public class Gui implements ActionListener { JTextField screen; JButton off, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, bPoint, bClear, divideBtn, minusBtn, plusBtn,multiplyBtn, btn; String s0, s1, s2; public Gui(){ // set them into empty string s0 = s1 = s2 = ""; JFrame frame= new JFrame(); JPanel mainPanel= new JPanel(new BorderLayout()); JPanel btnPanel= new JPanel(new GridLayout(6,5)); Font font1 = new Font("Digital-7 Italic", Font.BOLD, 24); // create number buttons b0 = new JButton("0"); b1 = new JButton("1"); b2 = new JButton("2"); b3 = new JButton("3"); b4 = new JButton("4"); b5 = new JButton("5"); b6 = new JButton("6"); b7 = new JButton("7"); b8 = new JButton("8"); b9 = new JButton("9"); bClear = new JButton("C"); divideBtn = new JButton("/"); minusBtn = new JButton("-"); plusBtn = new JButton("+"); multiplyBtn = new JButton("x"); btn = new JButton("="); // create . button bPoint = new JButton("."); off = new JButton("OFF"); // Setting attribute for frame object frame.setTitle("Calculator"); frame.setSize(380, 400); frame.setResizable(true); screen=new JTextField("0"); screen.setFont(font1); screen.setEditable(false); screen.setHorizontalAlignment(SwingConstants.RIGHT); screen.setPreferredSize(new Dimension(100, 70)); // Add component on panel btnPanel.add(off); btnPanel.add(screen); btnPa

18th Sep 2019, 3:37 PM
Raji Faruq Adeola
Raji Faruq Adeola - avatar
2 Respostas
+ 1
Don't know if this is still relevant. It's hard to help with gui codes on SoloLearn as they don't run on the playground.
25th Feb 2020, 3:47 PM
Tashi N
Tashi N - avatar
0
The class PowerCalculater can manage one line expressions like: 3 *(4+75/5)- (4-23%7)/2 ((3+43)*(32-11) + 21)*(34-21) https://code.sololearn.com/cicAa55y1lSw/?ref=app
28th Feb 2020, 9:32 PM
Jegors Čemisovs
Jegors Čemisovs - avatar