#C11970. Pizza Order Cost Calculation
Pizza Order Cost Calculation
Pizza Order Cost Calculation
You are given a fixed menu of pizza toppings with their respective prices. Your task is to calculate the cost breakdown for a customer's pizza order by selecting a list of toppings. For each valid topping in the input, print the topping name and its price. Finally, print the total cost of the selected toppings.
If a selected topping does not exist in the menu, it is ignored. The total cost is defined as \(\text{total} = \sum_{i=1}^{k} p_i\) where \(p_i\) represents the price of each valid topping.
inputFormat
The first line contains an integer \(n\) representing the number of toppings selected. The following \(n\) lines each contain a string representing a topping name.
Note that the available toppings and their prices are fixed as follows:
pepperoni: 2.5 mushrooms: 1.75 onions: 1.0 sausage: 3.0 bacon: 2.75 extra cheese: 1.5 black olives: 1.25 green peppers: 1.5 pineapple: 2.0 spinach: 1.0
outputFormat
For each valid topping (in the order given in the input) that exists in the menu, output one line containing the topping name, a colon, a space, and its price. The last line should display the total cost in the format:
total:
If none of the selected toppings are valid, only print the total cost as 0. All floating point numbers should be printed as they are (do not enforce a fixed number of decimal places).
## sample4
pepperoni
mushrooms
extra cheese
pineapple
pepperoni: 2.5
mushrooms: 1.75
extra cheese: 1.5
pineapple: 2.0
total: 7.75
</p>