Basically, I have a price quoter that I am working on. The way it should work is:
The user selects the quantity of cards from the combo box.
In the textfield a price displays once selected. (i.e. 100 = $8.95).
(I have this segment working already.)
Next the user selects whether they need both sides of the card printed on or not.
Updated price displays. (i.e. 100 + both sides = $11.95)
Next comes the delivery timeframe (i.e. 100 + both + two days = 38.95)
And finally whether they need us to design their card or not (100 + both + 2 days + yes = 53.95)

I've been working at this for awhile now, and have determined the best way to go about this is to have if statements add values to the initial value. (i.e. 100 = 8.95, both = +3, two = +27, yes = +15, total =53.95)
The sides and delivery values depends on the selected quantity.

Any and all help is greatly appreciated. Here is the code:

import javax.swing.*;
import java.awt.event.*;

public class BCard extends JFrame
{
    private JPanel panel;
    //I commented these out until I can fix the problems in the code//

    //private JPanel panel2;
    //private JPanel panel3;
    //private JPanel panel4;
   // private JPanel panel5;
    //private JPanel panel6;
    //private JPanel panel7;
    private JLabel msgLbl;
    private JLabel lbl;
    private JLabel lbl2;
    private JRadioButton oneB;
    private JRadioButton bothB;
    private JRadioButton glossB;
    private JRadioButton matteB;
    private JRadioButton twoDB;
    private JRadioButton sevenB;
    private JRadioButton wksB;
    private JRadioButton reqB;
    private JRadioButton dontB;
    private JTextField bCTotal;
    private String[] bC = {"100", "250", "500", "1000", "2000"};
    private JComboBox bCQty;
    private ButtonGroup radioButtonGroupSd;
    private ButtonGroup radioButtonGroupQual;
    private ButtonGroup radioButtonGroupDel;
    private ButtonGroup radioButtonGroupDes;
    private final int WINDOW_WIDTH = 300;
    private final int WINDOW_HEIGHT = 200;
    boolean value = true;
    //double oneHun = 8.95;
    //double twoFif = 11.95;
    //double fiveHun = 12.95;
    //double oneThou = 13.95;
    //double twoThou = 27.95;
    //String oneHunS = Double.toString(oneHun);
    //String twoFifS = Double.toString(twoFif);
    //String fiveHunS = Double.toString(fiveHun);
    //String oneThouS = Double.toString(oneThou);
    //String twoThouS = Double.toString(twoThou);
    //double bCTot = 0;
    //double bCP = 0;
    //double deliv = 0;
    //double sides = 0;
    //double design = 0;
    //String bCTotl = Double.toString(bCTot);




    public BCard()
    {
        setTitle("Business Cards");
        setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        buildBCPanel();
        add(panel);
        //add(panel2);
        //add(panel3);
        //add(panel4);
        //add(panel5);
        //add(panel6);
        //add(panel7);
        setVisible(value);

    }

     private void buildBCPanel()
    {
        msgLbl = new JLabel("Select the criteria that fits your needs:");
        //Number of cards
        lbl = new JLabel("Quantity:");
        bCQty = new JComboBox(bC);
        //One or both sides printed
        oneB = new JRadioButton("One side");
        bothB = new JRadioButton("Both sides");
        //types of cards
        glossB = new JRadioButton("Gloss");
        matteB = new JRadioButton("Matte");
        //shipping time
        twoDB = new JRadioButton("Next Day");
        sevenB = new JRadioButton("Seven Days");
        wksB = new JRadioButton("Up to Two Weeks");
        // Need us to design card?
        reqB = new JRadioButton("Request Design");
        dontB = new JRadioButton("Don't Require");
        //Price quote
        lbl2 = new JLabel("Your total may be $");
        bCTotal = new JTextField(10);
        bCTotal.setEditable(false);


        radioButtonGroupSd = new ButtonGroup();
        radioButtonGroupSd.add(oneB);
        radioButtonGroupSd.add(bothB);
        radioButtonGroupQual = new ButtonGroup();
        radioButtonGroupQual.add(glossB);
        radioButtonGroupQual.add(matteB);
        radioButtonGroupDel = new ButtonGroup();
        radioButtonGroupDel.add(twoDB);
        radioButtonGroupDel.add(sevenB);
        radioButtonGroupDel.add(wksB);
        radioButtonGroupDes = new ButtonGroup();
        radioButtonGroupDes.add(reqB);
        radioButtonGroupDes.add(dontB);


        bCQty.addActionListener(new ComboListener());
        oneB.addActionListener(new RadioButtonListener());
        bothB.addActionListener(new RadioButtonListener());
        glossB.addActionListener(new RadioButtonListener());
        matteB.addActionListener(new RadioButtonListener());
        twoDB.addActionListener(new RadioButtonListener2());
        sevenB.addActionListener(new RadioButtonListener2());
        wksB.addActionListener(new RadioButtonListener2());
        reqB.addActionListener(new RadioButtonListener());
        dontB.addActionListener(new RadioButtonListener());
        //bCTotal.addActionListener(new TotalListener());
        //bCTotal.getDocument().addDocumentListener(new MyDocumentListener());

        panel = new JPanel();
        panel.add(msgLbl);
        //panel2 = new JPanel();
        panel.add(lbl);
        panel.add(bCQty);
        //panel3 = new JPanel();
        panel.add(oneB);
        panel.add(bothB);
        //panel4 = new JPanel();
        panel.add(glossB);
        panel.add(matteB);
       // panel5 = new JPanel();
        panel.add(twoDB);
        panel.add(sevenB);
        panel.add(wksB);
       // panel6 = new JPanel();
        panel.add(reqB);
        panel.add(dontB);
        //panel7 = new JPanel();
        panel.add(lbl2);
        panel.add(bCTotal);
    }

     
     private class ComboListener implements ActionListener
     {
        public void actionPerformed (ActionEvent e)
        {
            //turn double into string so it will show up in the JTextField
            double oneHun = 8.95;
            double twoFif = 11.95;
            double fiveHun = 12.95;
            double oneThou = 13.95;
            double twoThou = 27.95;
            String oneHunS = Double.toString(oneHun);
            String twoFifS = Double.toString(twoFif);
            String fiveHunS = Double.toString(fiveHun);
            String oneThouS = Double.toString(oneThou);
            String twoThouS = Double.toString(twoThou);
            JComboBox comboBox=(JComboBox) e.getSource();
            String s =(String) comboBox.getItemAt(comboBox.getSelectedIndex());
            
           if(bCQty.getSelectedItem() == "100")
            {
               bCTotal.setText(oneHunS);
              }
           else if(bCQty.getSelectedItem() == "250")
            {
               bCTotal.setText(twoFifS);
              }
            else if(bCQty.getSelectedItem() == "500")
            {
               bCTotal.setText(fiveHunS);
              }
            else if(bCQty.getSelectedItem() == "1000")
            {
               bCTotal.setText(oneThouS);
              }
            else if(bCQty.getSelectedItem() == "2000")
            {
               bCTotal.setText(twoThouS);
            }

        }
            
      
     }

     private class RadioButtonListener implements ActionListener
     {
        public void actionPerformed (ActionEvent e)
        {
            double oneHunB = 3.00;
            double twoFifB = 1.00;
            double fiveHunB = 1.00;
            double oneThouB = 2.00;
            double twoThouB = 4.00;

            
            if(e.getSource() == bothB && bCQty.getSelectedItem() == "100")
            {
                //sides = oneHunB;

            }
            else if(e.getSource() == bothB && bCQty.getSelectedItem() == "250")
            {
              	//sides = twoFifB;
            }
            else if(e.getSource() == bothB && bCQty.getSelectedItem() == "250")
            {
             	//sides = fiveHunB;
            }
            else if(e.getSource() == bothB && bCQty.getSelectedItem() == "1000")
            {
            	//sides = oneThouB;
            }
            else if(e.getSource() == bothB && bCQty.getSelectedItem() == "2000")
            {
            	//sides = twoThouB;
            }

        }
     }

     private class RadioButtonListener2 implements ActionListener
     {
        public void actionPerformed (ActionEvent e)
        {
            double oneHunD = 27;
            double twoFifD = 29;
            double fiveHunD = 33;
            double oneThouD = 41;
            double twoThouD = 57;
            
            if(e.getSource() == twoDB && bCQty.getSelectedItem() == "100")
            {
                //deliv = oneHunD;
            }
            else if(e.getSource() == twoDB && bCQty.getSelectedItem() == "250")
            {
                //deliv = twoFifD;
            }
            else if(e.getSource() == twoDB && bCQty.getSelectedItem() == "500")
            {
                //deliv = fiveHunD;
            }
            else if(e.getSource() == twoDB && bCQty.getSelectedItem() == "1000")
            {
                //deliv = oneThouD;
            }
            else if(e.getSource() == twoDB && bCQty.getSelectedItem() == "2000")
            {
                //deliv = twoThouD;
            }
        }
     }

     //private class TotalListener implements ActionListener
     {
        //public void actionPerformed (ActionEvent e)
        {
            //bCTot = bCP + deliv + sides + design;
            //bCTotal.setText(bCTotl);

        }
     }

    public static void main(String[] args)
     {
        BCard bCard = new BCard();


     }
}

are those all inner classes?

At first glance you code shold look like:

import javax.swing.*;
import java.awt.event.*;

public class BCard extends JFrame {

    private JPanel panel;
    //I commented these out until I can fix the problems in the code//
    //private JPanel panel2;
    //private JPanel panel3;
    //private JPanel panel4;
    // private JPanel panel5;
    //private JPanel panel6;
    //private JPanel panel7;
    private JLabel msgLbl;
    private JLabel lbl;
    private JLabel lbl2;
    private JRadioButton oneB;
    private JRadioButton bothB;
    private JRadioButton glossB;
    private JRadioButton matteB;
    private JRadioButton twoDB;
    private JRadioButton sevenB;
    private JRadioButton wksB;
    private JRadioButton reqB;
    private JRadioButton dontB;
    private JTextField bCTotal;
    private String[] bC = {"100", "250", "500", "1000", "2000"};
    private JComboBox bCQty;
    private ButtonGroup radioButtonGroupSd;
    private ButtonGroup radioButtonGroupQual;
    private ButtonGroup radioButtonGroupDel;
    private ButtonGroup radioButtonGroupDes;
    private final int WINDOW_WIDTH = 300;
    private final int WINDOW_HEIGHT = 200;
    boolean value = true;
    double oneHunB = 3.00;
    double twoFifB = 1.00;
    double fiveHunB = 1.00;
    double oneThouB = 2.00;
    double twoThouB = 4.00;
    double oneHun = 8.95;
    double twoFif = 11.95;
    double fiveHun = 12.95;
    double oneThou = 13.95;
    double twoThou = 27.95;
    //initialize quantitePrice to oneHun
    private double quantitePrice = oneHun;
    private double sidePrice;
    private double deliv;

    public BCard() {
        setTitle("Business Cards");
        setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        buildBCPanel();
        add(panel);
        //add(panel2);
        //add(panel3);
        //add(panel4);
        //add(panel5);
        //add(panel6);
        //add(panel7);
        setVisible(value);

    }

    private void buildBCPanel() {
        msgLbl = new JLabel("Select the criteria that fits your needs:");
        //Number of cards
        lbl = new JLabel("Quantity:");
        bCQty = new JComboBox(bC);
        //One or both sides printed
        oneB = new JRadioButton("One side");
        bothB = new JRadioButton("Both sides");
        //types of cards
        glossB = new JRadioButton("Gloss");
        matteB = new JRadioButton("Matte");
        //shipping time
        twoDB = new JRadioButton("Next Day");
        sevenB = new JRadioButton("Seven Days");
        wksB = new JRadioButton("Up to Two Weeks");
        // Need us to design card?
        reqB = new JRadioButton("Request Design");
        dontB = new JRadioButton("Don't Require");
        //Price quote
        lbl2 = new JLabel("Your total may be $");
        bCTotal = new JTextField(10);
        bCTotal.setEditable(false);


        radioButtonGroupSd = new ButtonGroup();
        radioButtonGroupSd.add(oneB);
        radioButtonGroupSd.add(bothB);
        radioButtonGroupQual = new ButtonGroup();
        radioButtonGroupQual.add(glossB);
        radioButtonGroupQual.add(matteB);
        radioButtonGroupDel = new ButtonGroup();
        radioButtonGroupDel.add(twoDB);
        radioButtonGroupDel.add(sevenB);
        radioButtonGroupDel.add(wksB);
        radioButtonGroupDes = new ButtonGroup();
        radioButtonGroupDes.add(reqB);
        radioButtonGroupDes.add(dontB);


        bCQty.addActionListener(new ComboListener());
        oneB.addActionListener(new RadioButtonListener());
        bothB.addActionListener(new RadioButtonListener());
        glossB.addActionListener(new RadioButtonListener());
        matteB.addActionListener(new RadioButtonListener());
        twoDB.addActionListener(new RadioButtonListener2());
        sevenB.addActionListener(new RadioButtonListener2());
        wksB.addActionListener(new RadioButtonListener2());
        reqB.addActionListener(new RadioButtonListener());
        dontB.addActionListener(new RadioButtonListener());
        //bCTotal.addActionListener(new TotalListener());
        //bCTotal.getDocument().addDocumentListener(new MyDocumentListener());

        panel = new JPanel();
        panel.add(msgLbl);
        //panel2 = new JPanel();
        panel.add(lbl);
        panel.add(bCQty);
        //panel3 = new JPanel();
        panel.add(oneB);
        panel.add(bothB);
        //panel4 = new JPanel();
        panel.add(glossB);
        panel.add(matteB);
        // panel5 = new JPanel();
        panel.add(twoDB);
        panel.add(sevenB);
        panel.add(wksB);
        // panel6 = new JPanel();
        panel.add(reqB);
        panel.add(dontB);
        //panel7 = new JPanel();
        panel.add(lbl2);
        panel.add(bCTotal);
    }

    private class ComboListener implements ActionListener {

        public void actionPerformed(ActionEvent e) {
            //turn double into string so it will show up in the JTextField

            if (bCQty.getSelectedItem() == "100") {
                quantitePrice = oneHun;
            } else if (bCQty.getSelectedItem() == "250") {
                quantitePrice = twoFif;
            } else if (bCQty.getSelectedItem() == "500") {
                quantitePrice = fiveHun;
            } else if (bCQty.getSelectedItem() == "1000") {
                quantitePrice = oneThou;
            } else if (bCQty.getSelectedItem() == "2000") {
                quantitePrice = twoThou;
            }
            updateResult();
        }
    }
//ComboListener will be more shorter if using an array

    /*private class ComboListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {
    double[] quantitePrices = {8.95, 11.95, 12.95, 13.95, 27.95};
    JComboBox comboBox = (JComboBox) e.getSource();
    quantitePrice = quantitePrices[comboBox.getSelectedIndex()];
    updateResult();
    }
    }*/
    private class RadioButtonListener implements ActionListener {

        public void actionPerformed(ActionEvent e) {

            //Here it is supposed that if the one side the the sides value is set to 0.
            if (e.getSource() == oneB) {
                sidePrice = 0;

            } else {
                if (e.getSource() == bothB) {
                    if (/*e.getSource() == bothB &&*/bCQty.getSelectedItem() == "100") {
                        sidePrice = oneHunB;
                    } else if (/*e.getSource() == bothB &&*/bCQty.getSelectedItem() == "250") {
                        sidePrice = twoFifB;
                    } else if (/*e.getSource() == bothB &&*/bCQty.getSelectedItem() == "250") {
                        sidePrice = fiveHunB;
                    } else if (/*e.getSource() == bothB &&*/bCQty.getSelectedItem() == "1000") {
                        sidePrice = oneThouB;
                    } else if (/*e.getSource() == bothB &&*/bCQty.getSelectedItem() == "2000") {
                        sidePrice = twoThouB;
                    }
                }
            }
            updateResult();
        }
    }

    private class RadioButtonListener2 implements ActionListener {

        public void actionPerformed(ActionEvent e) {
            double oneHunD = 27;
            double twoFifD = 29;
            double fiveHunD = 33;
            double oneThouD = 41;
            double twoThouD = 57;
            //next day choice
            if (e.getSource() == twoDB) {
                if (bCQty.getSelectedItem() == "100") {
                    deliv = oneHunD;
                } else if (bCQty.getSelectedItem() == "250") {
                    deliv = twoFifD;
                } else if (bCQty.getSelectedItem() == "500") {
                    deliv = fiveHunD;
                } else if (bCQty.getSelectedItem() == "1000") {
                    deliv = oneThouD;
                } else if (bCQty.getSelectedItem() == "2000") {
                    deliv = twoThouD;
                }
            }
            /*
            Put here the other choices (seven day and up to two week.
             */





            updateResult();
        }
    }

    private void updateResult() {
        double totale = quantitePrice + deliv + sidePrice /*+ design*/;
        bCTotal.setText(String.valueOf(totale));
    }

    public static void main(String[] args) {
        BCard bCard = new BCard();


    }
}

Hope it hepls.

@moutanna

The lack of oop just made me cry

Sorry but the guy is asking for help on his code and "AS HE IS".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.