#K44527. Tia's Cafe Menu Management
Tia's Cafe Menu Management
Tia's Cafe Menu Management
You are tasked with maintaining the menu of Tia's Cafe. The menu is managed by a sequence of operations provided as input. There are four types of operations:
- 1 dish price: Add a new dish to the menu with its price, or update the price if the dish already exists.
- 2 dish: Remove the dish from the menu. If the dish is not found, do nothing.
- 3 dish: Query the price of the dish. If the dish is present, output its price; otherwise, output "Not Found".
- 4: Calculate the average price of all dishes currently on the menu using the formula \(\frac{\sum_{i=1}^{n} p_i}{n}\). Output the average formatted with two decimal places. If there are no dishes, output "No Dishes".
All operations are given in order, and only operations of type 3 and 4 produce an output, which should be printed in the order they are encountered.
For example, given the operations:
8 1 pizza 500 1 burger 250 1 pasta 300 3 pizza 4 2 burger 3 burger 4
The output should be:
500 350.00 Not Found 400.00
inputFormat
The first line of input is an integer \(n\) representing the number of operations. The following \(n\) lines each contain an operation in one of the following formats:
1 dish price
2 dish
3 dish
4
outputFormat
For each operation of type 3 or 4, output a line containing the result. For type 3, output the dish's price or "Not Found". For type 4, output the average price with exactly two decimal places, or "No Dishes" if there are none.
## sample8
1 pizza 500
1 burger 250
1 pasta 300
3 pizza
4
2 burger
3 burger
4
500
350.00
Not Found
400.00
</p>