#C14437. Inventory Value Calculation
Inventory Value Calculation
Inventory Value Calculation
You are given records for various products in a warehouse. Each product record contains its price and the available quantity. Your task is to compute the total inventory value for each product.
The total inventory value is calculated by the formula: $$inventory\_value = price \times quantity$$
A product record is considered valid only if it has exactly two details: a non-negative price (a floating-point number) and a non-negative quantity (an integer). Any record with missing details, additional details, or invalid data types should be ignored.
inputFormat
The first line of input contains an integer T, representing the number of product records. Each of the following T lines contains a product record in the format: name price quantity
, where name
is a string (without spaces), price
is a floating-point number, and quantity
is an integer.
outputFormat
Output a JSON object representing the inventory value of each valid product. The keys of the JSON must be the product names and the corresponding values must be the computed inventory value formatted as a floating-point number. The keys should be in lexicographical order.## sample
3
apple 1.0 10
banana 0.5 30
cherry 2.0 15
{"apple":10.0,"banana":15.0,"cherry":30.0}