I recently started learning java, and decided to test my programming capabilities. Have you ever heard of the "If you pick up a penny one day then twice the pennies as the day before on the next day, you'd have over a million dollars in a month" ? Well I decided to make a gui to demonstrate. How it works is you enter the amount of days, then it displays how many dollars you have.
this is my code, please tell me what I'm doing wrong to not get the correct answer
package gui; import java.awt.Container; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; import javax.swing.SwingConstants; public class DoublePennyProject extends JFrame { private static final int WIDTH = 500; private static final int HEIGHT = 300; private JLabel DayL, DollarL; private JTextField DayTF, DollarTF; private JButton calculateB; private CalculateButtonHandler cbHandler; private ExitButtonHandler ebHandler; public DoublePennyProject() { DayL = new JLabel("Enter the amount of days: ", SwingConstants.RIGHT); DollarL = new JLabel("You have this many dollars: ", SwingConstants.RIGHT); DayTF = new JTextField(10); DollarTF = new JTextField(10); calculateB = new JButton("Calculate"); cbHandler = new CalculateButtonHandler(); calculateB.addActionListener(cbHandler); setTitle("Twice the Pennies"); Container pane = getContentPane(); pane.setLayout(new GridLayout(4, 2)); pane.add(DayL); pane.add(DayTF); pane.add(DollarL); pane.add(DollarTF); pane.add(calculateB); setSize(WIDTH, HEIGHT); setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); } private class CalculateButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { double Day = 0; double Dollar = 0; while(Day<63){ Day=Day+1; Dollar = (Day*2)/100; } Day = Double.parseDouble(DayTF.getText()); Dollar = Math.pow(Day, Dollar); DollarTF.setText(":: " +Dollar); } } public class ExitButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { System.exit(0); } }