Advertisement
alefhidalgo

Super Hard Sum

Jun 20th, 2011
1,653
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. import java.math.BigDecimal;
  2. import java.util.Scanner;
  3. /**
  4.  * Super Hard Sum
  5.  * @author alefhidalgo [at] gmail [dot] com
  6.  */
  7.  
  8. public class SuperHardSum {
  9.     public static void main(String args[]) {
  10.         Scanner in = new Scanner(System.in);
  11.         Scanner lineScanner = null;
  12.         BigDecimal sum = BigDecimal.ZERO;
  13.         while (in.hasNextLine()) {
  14.             lineScanner = new Scanner(in.nextLine());
  15.             while (lineScanner.hasNextBigDecimal()) {
  16.                 sum = sum.add(lineScanner.nextBigDecimal());
  17.             }
  18.             System.out.println(sum);
  19.             sum = BigDecimal.ZERO;
  20.         }
  21.  
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement