#C14211. Analyze Purchase Records
Analyze Purchase Records
Analyze Purchase Records
In this problem, you are given a series of purchase records from standard input. Each record is a line in the following format:
For example, a record could be: apple,4,0.5
.
Your task is to analyze these records and output a summary consisting of:
- The total number of unique items purchased.
- The total quantity of items purchased.
- The total expenditure, displayed with two decimal places.
- The name of the most frequently purchased item (determined by the total quantity purchased).
Assume that the input is non-empty and correctly formatted.
inputFormat
The input is read from standard input. Each line contains a purchase record in the format: item_name,quantity,price_per_unit
. There is no extra whitespace in the input.
outputFormat
Print exactly four lines:
- Total number of unique items purchased:
- Total quantity of items purchased:
- Total expenditure:
- Most frequently purchased item: <item_name>## sample
apple,4,0.5
banana,2,0.25
apple,2,0.5
orange,3,0.75
banana,1,0.25
Total number of unique items purchased: 3
Total quantity of items purchased: 12
Total expenditure: 6.00
Most frequently purchased item: apple
</p>