Source of JOptionPaneProgram.java


  1: 
  2: import javax.swing.*;
  3: 
  4: public class JOptionPaneProgram
  5: {
  6:    public static void main(String[] args)
  7:    {
  8:       String appleString;
  9:       appleString =
 10:          JOptionPane.showInputDialog("Enter number of apples:");
 11:       int appleCount;
 12:       appleCount = Integer.parseInt(appleString);
 13: 
 14:       String orangeString;
 15:       orangeString =
 16:          JOptionPane.showInputDialog("Enter number of oranges:");
 17:       int orangeCount;
 18:       orangeCount = Integer.parseInt(orangeString);
 19: 
 20:       int totalFruitCount;
 21:       totalFruitCount = appleCount + orangeCount;
 22: 
 23:       JOptionPane.showMessageDialog(
 24:          null, "The total number of fruits = " + totalFruitCount);
 25: 
 26:       System.exit(0);
 27:    }
 28: }
 29: