Skip to content
This repository was archived by the owner on Sep 27, 2022. It is now read-only.

Commit a41b867

Browse files
author
nedelcho-delchev-tues
committed
TASK #1
1 parent 60dc8bf commit a41b867

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require "csv"
2+
require "date"
3+
4+
income = 0.00
5+
expense = 0.00
6+
first_date = Date.strptime(ARGV[0], '%d/%m/%Y')
7+
last_date = Date.strptime(ARGV[1], '%d/%m/%Y')
8+
9+
CSV.foreach("bank.csv") do |row|
10+
current_date = Date.strptime(row[0],'%d/%m/%Y')
11+
if (current_date >= first_date) and (current_date <= last_date)
12+
income = income + row[1].to_f
13+
expense = expense + row[2].to_f
14+
end
15+
end
16+
17+
printf "%.2f,%.2f,%.2f", income, expense, income - expense

0 commit comments

Comments
 (0)