SHARE
TWEET

Untitled

a guest Apr 19th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top