// **************************************************************** // ScanInts.java // // Reads lines of text and sums the integer in each line. // // **************************************************************** import java.io.*; import java.util.*; public class ScanInts { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String line = ""; int val, sum=0; do { System.out.println("Enter a line of text:"); line = scan.nextLine(); if (line.length() > 0) { val = Integer.parseInt(line); sum = sum + val; } } while (line.length() > 0); System.out.println("The sum of the integers is " + sum); } }