Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. package test;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Scanner;
  5.  
  6. public class test1 {
  7.  
  8. public static void main(String args[]) {
  9. // TODO Auto-generated method stub
  10.  
  11. Scanner sc = new Scanner(System.in);
  12. ArrayList<Double> arrList = new ArrayList<Double>();
  13.  
  14. while (true) {
  15. double x = Double.parseDouble(sc.nextLine()); /* arrList.add(Double.parseDouble(sc.nextLine())); */
  16. System.out.println("Nhap them Y / N");
  17. arrList.add(x); /*Thieu add vao*/
  18. if(sc.nextLine().equalsIgnoreCase("N")) {
  19. break;
  20. }
  21. }
  22. double res = 0;
  23. for (int i = 0; i < arrList.size(); i++) {
  24. /* double num = arrList.get(i); */
  25. /* tinh tong cac day so, khong co in ra gi het System.out.println(num); */
  26. res += arrList.get(i);
  27. }
  28. System.out.println("Tong cua day so la: " + res);
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement