Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By wsaryada

Thread: Help! Code won't run in JOptionPane, displaying process complete

  1. #1
    765891 is offline Member
    Join Date
    Jan 2013
    Location
    'Murica
    Posts
    23
    Rep Power
    0

    Exclamation Help! Code won't run in JOptionPane, displaying process complete

    Hello I am Aaron,
    I am currently having troubles running this code, when i click on Program 6 it wont load, and will say process complete please help? Unnecessary code was removed, which was not pertaining to this question, that is why it states create me. Can you please state what or how im doing it wrong, or be kind and helpful and edit my coding. Thank you. Please reply soon, within 12 hours max! Please
    Java Code:
    
    import javax.swing.*;
    
    
    public class MenuSetUp
    {
        static Object[] menu = {"Program 2", "Program 4.", "Program 5", "Program 6.",
                                "Exit"};
        //This is the array list that will help give the user choices on what 
        //program to pick and run or will help exit the program if the program
        //if the user wants to exit.
        public static void main(String[] args)
        {
            {
                Object options = JOptionPane.showInputDialog(null,"Please select a "+
                                 " program :", "Menu", 3, null, menu, menu[0]);
                
                if (options == null || options.equals("Exit"))
                //This is the if statement that will be excuted
                // if the user selects exit
                {
                    System.out.print("The program is terminated");
                }
                else if(options.equals("Program 2"))
                {
                    //creat me
                }
                else if(options.equals("Program 4"))
                {
                    //create me
                }
                else if(options.equals("Program 5"))
                {
                    //creat me
                }
                else if(options.equals("Program 6"))
                {
                    //These are the varibles of the program
                    String a= " ";
                    String b= " ";
                    String c= " ";
                    String intro = " ";
                    double valOfA=0.0;
                    double valOfB=0.0;
                    double valOfC=0.0;
                    double eq=0.0;
                    double r1=0.0;
                    double r2=0.0;
                    double Root1=0.0;
                    double Root2=0.0;
                    int rerunOption = JOptionPane.YES_OPTION;
                    
                    //*************************************************************
                    //The message that is displayed in the intro of the 
                    //program
                    intro += "Hello and welcome to this Phenomenal program";
                    intro += "This program will you solve for the 2";
                    intro += "roots of a quadratic formula";
                    intro += "\nPlease enter your information as directed";
                    intro += "This program will ask you to enter the values";
                    intro += "of a, b and c and this wonderful program will";
                    intro += "do the rest as you relax for a second, this";
                    intro += "can help speed up, your homework, or";
                    intro += "assignment. Enjoy and have a nice day!";
    
    
                    //This is the actual introduction of the program
                    JOptionPane.showMessageDialog(null, intro, "Program 6",
                                JOptionPane.INFORMATION_MESSAGE);    
                    //*************************************************************
    
    
                    
                    //Asks the user to input the value of a
                    a = JOptionPane.showInputDialog(null, "Enter the value of a:"+
                                                    "Quadratic Formula Solver", 
                                                    JOptionPane.QUESTION_MESSAGE);
                    //The following code parses the string number input to an 
                    //integer   
                    //that is used for the calculations
                    valOfA = Double.parseDouble(a);
                    
                    //Asks the user to input the value of a
                    b = JOptionPane.showInputDialog(null, "Enter the value of b:"+
                                                    "Quadratic Formula Solver", 
                                                    JOptionPane.QUESTION_MESSAGE);
                    //The following code parses the string number input to
                    // an integer   
                    //that is used for the calculations
                    valOfB = Double.parseDouble(a);
                    
                    //Asks the user to input the value of a
                    c = JOptionPane.showInputDialog(null, "Enter the value of c:"+
                                                    "Quadratic Formula Solver", 
                                                    JOptionPane.QUESTION_MESSAGE);
                    //The following code parses the string number input to an 
                    //integer   
                    //that is used for the calculations
                    valOfC = Double.parseDouble(a);
                        
                    eq=Math.pow(valOfB,2)-(4*valOfA*valOfC);
                    /*This is the base of the quadratic equation/formula 
                     *excluding the -b 
                     *(Negative of the Y-Intercept) and the division of 2
                     *This is where the b ( is squared (b*b) then  substracted
                     *by the 4 
                     *which is also multiplied by the a and c (-4*a*c)
                     */
                     
                    r1 = ((0-valOfB)+Math.sqrt(eq));
                    //The First part of the quadratic equation/formula output,
                    // where the -b (Negative of the Y-Intercept)is added to
                    // the square
                    //root of the base (eq)
                    
                    r2 = ((0-valOfB)-Math.sqrt(eq));
                    //The First part of the quadratic equation/formula output 
                    //where the -b 
                    //(Negative of the Y-Intercept)is substracted to the square 
                    //root of the base (eq)
                    
                    Root1 = (r1/2)*valOfA;
                    //The Second part of the quadratic equation/formula output
                    // where the -b  
                    //added to the the  square root of the base (eq) is divided
                    // by 2
                    // then multiplied by  a
                    
                    Root2 = (r2/2)*valOfA;
                    //The Second part of the quadratic equation/formula output
                    // where the -b 
                    // substracted to the the  square root of the base (eq) is
                    // divided by 2 a
                    // then multiplied by a
                    
                    //The final output of the program
                    JOptionPane.showMessageDialog(null, "The value of Root 1 is " +
                                                   Root1 +" The value of Root 2 is ",
                                                   "Program 6", 
                                                  JOptionPane.INFORMATION_MESSAGE);
                }
            }
        }
    }
    Last edited by 765891; 03-21-2013 at 05:15 AM.

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    758
    Rep Power
    8

    Default Re: Help! Code won't run in JOptionPane, displaying process complete

    Hello,

    Can you spot the cause of error from these lines?

    Java Code:
    static Object[] menu = {"Program 2", "Program 4.", "Program 5", "Program 6.", "Exit"};
    Java Code:
    else if(options.equals("Program 6"))
    Last edited by wsaryada; 03-21-2013 at 05:31 AM.
    765891 likes this.

  3. #3
    765891 is offline Member
    Join Date
    Jan 2013
    Location
    'Murica
    Posts
    23
    Rep Power
    0

    Default Re: Help! Code won't run in JOptionPane, displaying process complete

    Life saved :) Mother of god. You saved me from a panic attack!

Similar Threads

  1. Replies: 1
    Last Post: 12-14-2011, 10:23 PM
  2. I need urgent help to complete this code please!
    By kenson02 in forum New To Java
    Replies: 3
    Last Post: 12-14-2011, 02:37 AM
  3. complete the code
    By blackz in forum New To Java
    Replies: 2
    Last Post: 09-11-2011, 02:04 AM
  4. displaying tables in joptionpane
    By kaemonsaionji in forum New To Java
    Replies: 2
    Last Post: 02-26-2009, 06:53 AM
  5. Replies: 1
    Last Post: 07-31-2007, 04:01 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •