Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package test;
- import java.util.ArrayList;
- import java.util.Scanner;
- public class test1 {
- public static void main(String args[]) {
- // TODO Auto-generated method stub
- Scanner sc = new Scanner(System.in);
- ArrayList<Double> arrList = new ArrayList<Double>();
- while (true) {
- double x = Double.parseDouble(sc.nextLine()); /* arrList.add(Double.parseDouble(sc.nextLine())); */
- System.out.println("Nhap them Y / N");
- arrList.add(x); /*Thieu add vao*/
- if(sc.nextLine().equalsIgnoreCase("N")) {
- break;
- }
- }
- double res = 0;
- for (int i = 0; i < arrList.size(); i++) {
- /* double num = arrList.get(i); */
- /* tinh tong cac day so, khong co in ra gi het System.out.println(num); */
- res += arrList.get(i);
- }
- System.out.println("Tong cua day so la: " + res);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement