// Test Program #4 // MaxSum.txt - Read a sequence of numbers terminated by 0, then // print the sum of the numbers and the largest number. public class MaxSum{ public MaxSum() { super(); } public int max(int a, int b) { if (a > b) return a; else return b; } public static void main() { int n; // Current input number int largest;// largest number read int sum; // sum of the input numbers MaxSum m; JFSystem sys; sys = new JFSystem(); m = new MaxSum(); // Read and process input numbers sum = 0; n = sys.get(); largest = n; while (n != 0) { sum = sum + n; largest = (m).max(n, largest); n = sys.get(); } // Print the total of input nubmers and the largest input number. sys.put(sum); sys.put(largest); } }