Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Computer Science

I cannot figure out what is going on with my code!!!

with my code i get these errors: Exception in thread "AWT-EventQueue-0" java.util.UnknownFormatConversionException: Conversion = '-' at java.base/java.util.Formatter.parse(Formatter.java:2830) at java.base/java.util.Formatter.format(Formatter.java:2751) at java.base/java.util.Formatter.format(Formatter.java:2705) at java.base/java.lang.String.format(String.java:4138) at RestaurantBill$Total.actionPerformed(RestaurantBill.java:132) at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972) at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2313) at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405) at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262) at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279) at java.desktop/java.awt.Component.processMouseEvent(Component.java:6616) at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3398) at java.desktop/java.awt.Component.processEvent(Component.java:6381) at java.desktop/java.awt.Container.processEvent(Container.java:2266) at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4991) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4823) at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948) at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575) at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310) at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4823) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:775) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:747) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:744) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

here is my code: import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField;

public class RestaurantBill extends JFrame { private int FRAME_WIDTH = 400; private int FRAME_HEIGHT = 400; private int FIELD_WIDTH = 2; private int Height = 30; private int Width = 30; private JTextField box; private JTextField box2; private JFrame frame; JPanel panel; private JLabel label1; private JButton button1; private JTextArea billArea; private double Balance; private double Tax; private double Tip; private double Total; private double TotalAll = 0; private boolean ctrl = true;

public static void main(String[] args) {
    new RestaurantBill();
}

public RestaurantBill() {
    frame = new JFrame();
    frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
    frame.setTitle("Restaurant Bill");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    panel = new JPanel();

    label1 = new JLabel("Tax");
    panel.add(label1);

    box = new JTextField("5.6");
    panel.add(box);

    label1 = new JLabel("%");
    panel.add(label1);

    label1 = new JLabel("Tip");
    panel.add(label1);

    box = new JTextField("15");
    panel.add(box);

    label1 = new JLabel("%");
    panel.add(label1);

    button1 = new JButton("Hamburger");
    panel.add(button1);
    button1.addActionListener(new Hamburger());

    button1 = new JButton("Quesadilla");
    panel.add(button1);
    button1.addActionListener(new Quesadilla());

    button1 = new JButton("Tacos and Rice");
    panel.add(button1);
    button1.addActionListener(new TacosandRice());

    button1 = new JButton("Enchiladas");
    panel.add(button1);
    button1.addActionListener(new Enchiladas());

    button1 = new JButton("Pozole");
    panel.add(button1);
    button1.addActionListener(new Pozole());

    button1 = new JButton("Total");
    panel.add(button1);
    button1.addActionListener(new Total());

    button1 = new JButton("Clear");
    panel.add(button1);
    button1.addActionListener(new Clear());

    billArea = new JTextArea(Height, Width);
    panel.add(billArea);

    frame.setVisible(true);
    frame.add(panel);
}

public class Hamburger implements ActionListener {
    public void actionPerformed(ActionEvent event) {
        billArea.append(String.format("%-30s %9.2f\n", "Hamburger", 6.99));
        TotalAll += 6.99;
    }
}

    public class Quesadilla implements ActionListener {
        public void actionPerformed(ActionEvent event) {
            billArea.append(String.format("%-30s %9.2f\n", "Quesadilla", 4.99));
            Total += 4.99;
        }
    }

    public class TacosandRice implements ActionListener {
            public void actionPerformed(ActionEvent event) {
                billArea.append(String.format("%-30s %9.2f\n", "Tacos and Rice", 8.99));
                Total += 8.99;
    }
}
    public class Enchiladas implements ActionListener {
        public void actionPerformed(ActionEvent event) {
            billArea.append(String.format("%-30s %9.2f\n", "Enchiladas", 5.99));
            Total += 5.99;
        }
    }
    public class Pozole implements ActionListener {
        public void actionPerformed(ActionEvent event) {
            billArea.append(String.format("%-30s %9.2f\n", "Pozole", 10.99));
            Total += 10.99;
        }
    }
     class Total implements ActionListener {
        public void actionPerformed(ActionEvent event) {
        if (ctrl == true) {
            billArea.append(String.format("-------------------------" + "---------------\n"));
            billArea.append(String.format("%-30 $%9.2f\n", "Pretax Total", Total));
            Tax = Double.parseDouble(box.getText());
            double Rate =(Tax / 100) * Total;
            billArea.append(String.format("%-30 $%9.2f\n", "Tax", Rate));
            billArea.append("------------------------" + "  ---------\n");
            Balance = Total + Rate;
            billArea.append(String.format("%-30s $%9.2f\n", "Total w/Tax", Balance));
            Tip = Double.parseDouble(box2.getText());
            double Rate2 = (Tip / 100) * Total;
            billArea.append(String.format("%-30s $%9.2f\n", "Tip", Rate2));
            billArea.append("------------------------" + "  ---------\n");
            TotalAll = Balance + Rate2;
            billArea.append(String.format("%-30s $%9.2f\n", "Total", TotalAll));
        }
        ctrl = false;
        }
    }
    public class Clear implements ActionListener {
        public void actionPerformed(ActionEvent event) {
            billArea.setText("");
            TotalAll = 0;
        }
    }

    }