Beginner Beginners Problems > Ad-hoc

Now a days POS (Point of sales) systems are becoming very common in our country. You will find them in almost every shop in the major cities. These are the system in the cash counter where the sales person enters detail of your purchased products either manually or through scanning machine and the system automatically calculates the total amount. This helps in quick sale and thus shops can provide better customer service. This system is an essential part of growing business. Not only this helps in quick sales, but it also keeps track of every sale made in great detail. It can later help the shop owner to understand the profit margin of the business. It can also give an idea which product is in demand and when it is in demand. In summary this provides great business intelligence. In this problem, we are going to write a simple POS system total amount calculation logic, so that we can integrate that in a POS system in future. You are the programmer who is assigned to complete this important task. Let's do it. Input: ------ Input starts with an integer **T (1 <= T <=50)**, denoting the number of test cases. Each case starts with an integer **N (1 ≤ N ≤ 20)** denoting the number of items purchased. The next N lines will contain two number P and Q separated by space, denoting the unit price of an item and quantity purchase of that item. Here **P (1.00 ≤ P ≤ 2000.00)** is always a real number and **Q (1 ≤ Q ≤ 20)** is always a whole number. Each test case ends with an integer **G (1 ≤ G ≤ 2<sup>31</sup>-1)** that denotes the cash amount given by the customer to sales person. This amount will always be greater than or equal to the total amount of purchase. Output: ------- For each case of input, print the case number as "**Case #:** " and output the amount to be returned by the sales person to customer in single line. You can assume this amount will always be less than 1000.00. In case the return amount is fractional (i.e 115.73), the sales person will only return the whole amount (115) and discard the fractional amount (0.73). *Please check the sample input/output for better understanding of format.* Sample Input ------------ 3 2 500.00 2 30.00 1 1100 1 45.80 2 500 3 99.99 4 1.50 2 33.33 3 1000 Sample Output ------------- Case 1: 70 Case 2: 408 Case 3: 497

MD. Jalal Uddin