#C14211. Analyze Purchase Records

    ID: 43836 Type: Default 1000ms 256MiB

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:

item_name,quantity,price_per_unititem\_name,quantity,price\_per\_unit

For example, a record could be: apple,4,0.5.

Your task is to analyze these records and output a summary consisting of:

  1. The total number of unique items purchased.
  2. The total quantity of items purchased.
  3. The total expenditure, displayed with two decimal places.
  4. 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:

  1. Total number of unique items purchased:
  2. Total quantity of items purchased:
  3. Total expenditure:
  4. 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>