Advertisement
meteor4o

Java-Fund-DataLab- 03.ExactSumRealNumbers

May 29th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.math.BigDecimal;
  4. import java.util.Scanner;
  5.  
  6. public class Main {
  7.  
  8. public static void main(String[] args) {
  9.  
  10. Scanner sc = new Scanner(System.in);
  11. int n = Integer.parseInt(sc.nextLine());
  12. BigDecimal input = new BigDecimal(0);
  13.  
  14. BigDecimal sum = new BigDecimal(0);
  15.  
  16. for (int i = 1; i <= n; i++) {
  17. input = new BigDecimal(sc.nextLine());
  18. sum = sum.add(input);
  19. }
  20. System.out.println(sum);
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement