Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. public class LineTotaller {
  2.  
  3. public static void main(String[] args) {
  4. int total = 0;
  5.  
  6. Scanner keyboard = new Scanner(System.in);
  7. System.out.println("Enter a list of integers: ");
  8. String input = keyboard.nextLine();
  9. Scanner chopper = new Scanner(input);
  10.  
  11. while(chopper.hasNextInt()) {
  12. total = total + chopper.nextInt();
  13. }
  14.  
  15. System.out.println(total);
  16. }
  17.  
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement