Advertisement
Parasect

uni with arrays

Dec 2nd, 2013
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2. public class pears {
  3. public static void main(String[] args) {
  4. int total = 0;
  5. String x = JOptionPane.showInputDialog("enter nums please");
  6. String[] split = x.split("\\s+");
  7. for (int i = 0; i < split.length; i++){
  8. total += Integer.parseInt(split[i]);
  9. }
  10. JOptionPane.showMessageDialog(null, "the sum is" + total);
  11.  
  12. }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement