Advertisement
wadkat

JOptionPane basic

Nov 2nd, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. package javaapplication7;
  2.  
  3. /**
  4. *
  5. * @author pclab
  6. */
  7. import javax.swing.JOptionPane;
  8. public class JavaApplication7 {
  9.  
  10. /**
  11. * @param args the command line arguments
  12. */
  13. public static void main(String[] args) {
  14. // TODO code application logic here
  15. String Apple, Orange;
  16. int app, ora, total;
  17.  
  18. Apple=JOptionPane.showInputDialog("Enter no of apples");
  19. //** stored as string
  20. Orange=JOptionPane.showInputDialog("Enter no of Oranges");
  21.  
  22. app=Integer.parseInt(Apple);
  23. ora=Integer.parseInt(Orange);
  24. total=app+ora;
  25. JOptionPane.showMessageDialog(null,"total fruits: "+total);
  26. System.exit((0));
  27.  
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement