Viết chương trình:
<name>,<qty>,<price> (qty là số nguyên, price là double, không chứa khoảng trắng).data.csv với header name,qty,price, sau đó N dòng nội dung — dùng BufferedWriter.data.csv bằng BufferedReader, bỏ qua header. Với mỗi dòng:
split(",")qty và price * qty vào tổng.totalQty: <tổng qty>
totalRevenue: <tổng price*qty, 2 chữ số thập phân locale US>
<name>,<qty>,<price>2 dòng totalQty: ... và totalRevenue: ...
Ví dụ:
Đầu vào:
3
apple,10,2.5
banana,5,1.0
cherry,20,3.0
Đầu ra:
totalQty: 35
totalRevenue: 90.00
Giải thích:
Đầu vào:
1
solo,7,12.50
Đầu ra:
totalQty: 7
totalRevenue: 87.50
Giải thích:
Đầu vào:
2
x,0,1000
y,0,2000
Đầu ra:
totalQty: 0
totalRevenue: 0.00
Giải thích:
Đầu vào:
4
p1,1,1
p2,2,2
p3,3,3
p4,4,4
Đầu ra:
totalQty: 10
totalRevenue: 30.00
Đang tải editor...