Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class LineTotaller {
- public static void main(String[] args) {
- int total = 0;
- Scanner keyboard = new Scanner(System.in);
- System.out.println("Enter a list of integers: ");
- String input = keyboard.nextLine();
- Scanner chopper = new Scanner(input);
- while(chopper.hasNextInt()) {
- total = total + chopper.nextInt();
- }
- System.out.println(total);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement