#C13629. Calculate Total Prices
Calculate Total Prices
Calculate Total Prices
You are given a list of items. Each item is described by three values: a name (a string), a price (a floating-point number), and a quantity (an integer or a floating-point number). Your task is to compute the total price for each item using the formula \(\text{total_price} = \text{price} \times \text{quantity}\) and output the results.
For every item, print the name followed by its computed total price. If the computed \(\text{total_price}\) is an integer, output it without a decimal point; otherwise, display it with one digit after the decimal point.
For example, if an item is specified as "apple 0.5 10", then the total price will be \(0.5 \times 10 = 5.0\), so the output line should be:
apple 5.0
inputFormat
The input is read from standard input (stdin) with the following format:
- The first line contains an integer \(n\) indicating the number of items.
- The next \(n\) lines each contain an item's details: a string name, a floating-point number price, and a number quantity, separated by spaces.
For instance:
3 apple 0.5 10 banana 0.25 20 orange 0.75 5
outputFormat
For each item, output a single line containing the name and the computed total price, separated by a space. The total price is calculated as:
\(\text{total_price} = \text{price} \times \text{quantity}\)
If the result is an integer, print it without a decimal; otherwise, print it with one decimal place.
For example:
apple 5.0 banana 5.0 orange 3.75## sample
3
apple 0.5 10
banana 0.25 20
orange 0.75 5
apple 5.0
banana 5.0
orange 3.75
</p>