#K79582. Daily Sales Report
Daily Sales Report
Daily Sales Report
You are given a list of transaction records. Each record consists of a transaction ID, a date in the format YYYY-MM-DD
, a customer ID, and an amount representing the value of the transaction.
Your task is to generate a daily sales report. For each unique date, calculate the following:
- Total Sales: The sum of all transaction amounts for that date.
- Unique Customers: The number of unique customer IDs for that date.
- Transactions: The total number of transactions on that date.
The output should list the reports sorted by date in ascending order. Use stdin
to read the input and stdout
to print the result.
Note: If no transactions are provided, no output should be produced.
inputFormat
The input is provided via stdin with the following format:
- The first line contains an integer n representing the number of transactions.
- The following n lines each contain a transaction record with 4 space-separated fields:
transaction_id
(string) - an identifier for the transactiondate
(string) - in the format \(\texttt{YYYY-MM-DD}\)customer_id
(string) - an identifier for the customeramount
(float) - the sale amount
outputFormat
The output should be printed to stdout and consist of one line per unique date. Each line must display 4 space-separated values:
date
- the date of the transactionstotal_sales
- the sum of amounts on that date (displayed with one decimal place)unique_customers
- the number of unique customerstransactions
- the total number of transactions
The reports should be output in ascending order by date.
## sample5
1 2023-10-01 C1 100.0
2 2023-10-01 C2 150.0
3 2023-10-02 C1 200.0
4 2023-10-02 C3 50.0
5 2023-10-02 C1 75.0
2023-10-01 250.0 2 2
2023-10-02 325.0 2 3
</p>