Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: My program doesnt want to do its math point my errors out please

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default My program doesnt want to do its math point my errors out please

    Hey guys i am making a money converter but i cant seem to see what is the problem for all the gates that i put in. Ii even put testers in. I got my problem but i dont know how to fix it. I am trying my best
    Excuse my English its not the best
    Here is my GUI

    /*
     
    package fase3;
     
    /**
     *
     * @author Jigsaw
     */
    public class Converter extends javax.swing.JFrame {
     
        /** Creates new form Converter */
        public Converter() {
            initComponents();
        }
     
        Driver dr = new Driver();
     
        double num =0;
        double numout = 0;
        double blah = 0;
     
        int EurotoSA = 0;
        int USAtoSA = 0;
        int SAtoEuro = 0;
        int EurotoUSA = 0;
        int USAtoEuro = 0;
        int SAtoUSA = 0;
     
    ( I removed all this coding cause i got this right nothing to do with what my problem is )
     
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
     
            num = Integer.parseInt(jTextField1.getText());
            dr.getNum(num);
            numout = dr.setNum(blah);
            jLabel1.setText("Test 1 : " + dr.numD);
            jLabel2.setText("Test 2 : " + dr.SAtoEuro);
            jTextField2.setText ("" +numout);
     
        }
     
        private void SouthAfricanOUTActionPerformed(java.awt.event.ActionEvent evt) {
        }
     
        private void SouthAfricaINActionPerformed(java.awt.event.ActionEvent evt) {
     
           SouthAfricanOUT.setEnabled(false);
           EuropeOUT.setSelected(true);
     
            if(SouthAfricaIN.isSelected() && EuropeOUT.isSelected()){
                SAtoEuro = 1;
                SAtoUSA = 0;
                USAtoSA = 0;
                USAtoEuro = 0;
                EurotoUSA = 0;
                EurotoSA = 0;
     
                dr.gate1(SAtoEuro);
            }
                   if(SouthAfricaIN.isSelected() && AmericaOUT.isSelected()){
                SAtoEuro = 0;
                SAtoUSA = 1;
                USAtoSA = 0;
                USAtoEuro = 0;
                EurotoUSA = 0;
                EurotoSA = 0;
                dr.gate1(SAtoEuro);
            }
     
        }
     
        private void AmericaINActionPerformed(java.awt.event.ActionEvent evt) {
     
        }
     
        private void EuropeINActionPerformed(java.awt.event.ActionEvent evt) {
     
        }
     
        private void AmericaOUTActionPerformed(java.awt.event.ActionEvent evt) {
     
        }
     
        private void EuropeOUTActionPerformed(java.awt.event.ActionEvent evt) {
     
        }
     
        private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
            new Help().setVisible(true);
        }
     
        private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
            System.exit(0);
        }
     
     
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
     
                public void run() {
                    new Converter().setVisible(true);
                }
            });
        }
        // Variables declaration - do not modify
        private javax.swing.JRadioButton AmericaIN;
        private javax.swing.JRadioButton AmericaOUT;
        private javax.swing.JRadioButton EuropeIN;
        private javax.swing.JRadioButton EuropeOUT;
        private javax.swing.JRadioButton SouthAfricaIN;
        private javax.swing.JRadioButton SouthAfricanOUT;
        private javax.swing.ButtonGroup buttonGroup1;
        private javax.swing.ButtonGroup buttonGroup2;
        private javax.swing.ButtonGroup buttonGroup3;
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JMenu jMenu1;
        private javax.swing.JMenuBar jMenuBar1;
        private javax.swing.JMenuItem jMenuItem1;
        private javax.swing.JPanel jPanel1;
        private javax.swing.JTextField jTextField1;
        private javax.swing.JTextField jTextField2;
        // End of variables declaration
    }

    Here my driver class this is where the math goes.

    package fase3;
     
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
     
    /**
     *
     * @author Jigsaw
     */
    public class Driver {
     
        double num = 0;
        double numD = 0;
     
        double USAtoSAcur = 7.022;
        double USAtoEUROcur = 1.393;
        double SAtoEUROcur = 9.785;
     
        int EurotoSA = 0;
        int USAtoSA = 0;
        int SAtoEuro = 0;
        int EurotoUSA = 0;
        int USAtoEuro = 0;
        int SAtoUSA = 0;
     
        public double getNum(double inNum) {
            num = inNum;
            return num;
        }
        public int gate1(int StoE){
            SAtoEuro = StoE;
            return SAtoEuro;
        }
     
        public void Cu1(){
     
            if (SAtoEuro == 1){
                numD = num*SAtoEUROcur;
            }
        }
     
        public double  setNum(double numOUT) {
            numOUT = numD;
            return numOUT;
        }
     
     
     
    }

    Also another thing i made another frame that helps dummies like a tutorial. But if you press on the X top right it closes my whole program. How do i make it so that it only closes that frame and not the whole program?
    Last edited by Redlight; October 31st, 2010 at 02:27 AM.


  2. #2
    Junior Member
    Join Date
    Apr 2010
    Location
    Italy
    Posts
    15
    Thanks
    1
    Thanked 3 Times in 3 Posts

    Default Re: My program doesnt want to do its math point my errors out please

    Hi redlight,
    in your code there isn't initComponents(), so there isn't GUI! I can't help u!
    Bye

  3. #3
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    491
    Thanks
    8
    Thanked 47 Times in 45 Posts

    Default Re: My program doesnt want to do its math point my errors out please

    Quote Originally Posted by lucasantos View Post
    in your code there isn't initComponents(), so there isn't GUI!
    Absolute rubbish.
    Quote Originally Posted by lucasantos View Post
    I can't help u!
    That much is sure.

    db

  4. #4
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    491
    Thanks
    8
    Thanked 47 Times in 45 Posts

    Default Re: My program doesnt want to do its math point my errors out please

    i cant seem to see what is the problem for all the gates that i put in. Ii even put testers in
    Sorry, but I have no idea what you mean by gates or testers.

    What I do see is a lot of IDE generated code including a whole lot of empty methods. I recommend you go through these tutorials:
    Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials)

    db

Similar Threads

  1. Help need on math java program
    By zidangus in forum What's Wrong With My Code?
    Replies: 6
    Last Post: July 6th, 2010, 07:41 PM
  2. i can run my program but the math doesnt come otu
    By pairenoid in forum What's Wrong With My Code?
    Replies: 0
    Last Post: May 7th, 2010, 01:39 PM
  3. my menu doesnt work can u tell me whats wrong
    By claymore in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 8th, 2010, 03:16 AM
  4. JFrame, frame's title doesnt appear.
    By chronoz13 in forum AWT / Java Swing
    Replies: 1
    Last Post: November 26th, 2009, 02:38 PM
  5. math quiz program
    By hope.knykcah in forum Collections and Generics
    Replies: 1
    Last Post: October 23rd, 2009, 09:53 AM