Advertisement
Parasect

Untitled

Dec 2nd, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1.  
  2. import javax.swing.JOptionPane;
  3.  
  4. public class apples {
  5.  
  6. public static void main(String[] args) {
  7. int total = 0;
  8. String x = JOptionPane.showInputDialog("enter nums please");
  9.  
  10. for (int i = 0; i<=15;i++){
  11. String s1 = x.substring (0, x.indexOf(' '));
  12. total = total + Integer.parseInt(s1);
  13. int y = x.indexOf(' ') + 1;
  14. x = x.substring(y);
  15. }
  16. JOptionPane.showMessageDialog(null, "the sum is" + total);
  17.  
  18. }
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement