import java.util.*; interface Sum<T> { void add(T x); } class FloatSum implements Sum<Float> { float val = 0; public void add(Float x) { val += x.floatValue(); } public String toString() { return String.valueOf(val); } } class IntSum implements Sum<Integer> { int val = 0; public void add(Integer x) { val += x.intValue(); } public String toString() { return String.valueOf(val); } } class LLNew<T> { T data; LLNew<T> next; LLNew(T d, LLNew<T> n) { data = d; next = n; } Sum<T> printAndSum(Sum<T> summer) { System.out.println(data); summer.add(data); if (next != null) next.printAndSum(summer); return summer; } public static void main(String[] args) { LLNew<Float> flist = null; LLNew<Integer> ilist = null; Scanner in = new Scanner(System.in); while (in.hasNextDouble()) { double d = in.nextDouble(); flist = new LLNew<Float>((float)d, flist); ilist = new LLNew<Integer>((int)d, ilist); } System.out.println("Floating sum: " + flist.printAndSum(new FloatSum()) + "\n"); System.out.println("Integer sum: " + ilist.printAndSum(new IntSum()) + "\n"); } }