Web Design and Web Development Forum

  1. #1
    Join Date
    Feb 2009
    Posts
    2
    Rep Power
    0
  2. laruera is on a distinguished road
  3. Help with simple code (JOptionPane)

    I tired to compile the code below and could not get it to work, its right out of the text book. Could someone please help look at this and figure out what is wrong? Thanks a bunch.
    Code:
    import javax.swing.JOptionPane;
    public class JOptionPaneDemo
    {
    public static void main(String[] args)
    {
    String appleString = JOptionPane.sowInputDialog("Enter number of apples:");
    int appleCount = Integer.parseInt(appleString);
    String orangeString = JOptionPane.showInputDialog("Enter number of oranges:);
    int orangeCount = Integer.parseInt(orangeString);
    Int totalFruitCount = appleCount + orangeCount;
    JOptionPane.showMessageDialog(null,"The total number of fruits = " + totalFruitCount;
    System.exit(0);
    }
    }
    Last edited by callumjones; 02-15-2009 at 07:02 PM. Reason: Inserting code tags
    Reply With Quote Reply With Quote
  4. #2
    Join Date
    Feb 2009
    Posts
    2
    Rep Power
    0
  5. laruera is on a distinguished road
  6. Re: Help with simple code (JOptionPane)

    Well I found typographical and grammatical errors and now this code is working...
    Thanks...
    //below is the code that is working

    import javax.swing.JOptionPane;
    public class JOptionPaneDemo
    {
    public static void main(String[] args)
    {
    String appleString = JOptionPane.showInputDialog("Enter number of apples:");
    int appleCount = Integer.parseInt(appleString);
    String orangeString = JOptionPane.showInputDialog("Enter number of oranges:");
    int orangeCount = Integer.parseInt(orangeString);
    int totalFruitCount = appleCount + orangeCount;
    JOptionPane.showMessageDialog(null,"The total number of fruits = " + totalFruitCount);
    System.exit(0);
    }
    }
    Reply With Quote Reply With Quote
  7. #3
    gorda001's Avatar
    Join Date
    Jun 2005
    Location
    <0x79a3f6>
    Posts
    4,851
    Rep Power
    11
  8. gorda001 is on a distinguished road
  9. Re: Help with simple code (JOptionPane)

    Please use [code][/code] tags when posting code. :)
    Reply With Quote Reply With Quote

Similar Threads

  1. Can anyone help fix this code? Should be pretty simple
    By John D in forum HTML/CSS Coding
    Replies: 10
    Last Post: 01-05-2007, 10:16 AM
  2. Using PHP - Cleaning Up Code
    By aliasxneo in forum PHP Articles
    Replies: 12
    Last Post: 12-19-2006, 02:40 PM