PCC15D - GST Calculator

Maslee is a student at a public university. Since the implementation of Good and Services Tax (GST), the prices for food at cafeterias in the university have become more expensive and Maslee has decided to cook his own meal.

GST rates are classified into two types, which are:

  1. Standard-Rated (SR) Standard-rated supplies are taxable supplies of goods and services which are subject to a proposed rate of 6%.
  2. Zero-Rated (ZR) Zero-rated supplies are taxable supplies of goods and services which are subject to GST at 0% rate.

Below is an example of a receipt after GST:

Item Quantity Price GST Rates
Meksis Prepaid 1 30.00 SR
Jati Rice 1 32.00 ZR
Rybena Juice 2 18.00 SR
Peanut Butter 5 4.50 SR
Total Amount Including GST 125.81
Total Amount GST Paid 5.31


And this is how to calculate the new prices for goods and services after GST:

    Meksis Prepaid 1 x RM30.00 = RM30.00 + 6% =  RM31.80
    Jati Rice      1 x RM32.00 = RM32.00 + 0% =  RM32.00
    Rybena Juice   2 x RM18.00 = RM36.00 + 6% =  RM38.16
    Peanut Butter  5 x  RM4.50 = RM22.50 + 6% =  RM23.85
    ---------------------------------------------------- +
                          Total Including GST = RM125.81

Your task is to make a simple calculator to help Maslee to calculate the total amount that Maslee needs to pay for items and services after GST and the amount of GST paid for the items and services.

Input

Input consists of integer T denoting number of test cases. Each test case consists of integer N denoting number of items followed by N-lines of item details (name, quantity, price, and GST-rate). Item name will consists of single string, and price are rounded to 2 decimal places.

Output

For each test case, output consists of case number followed by 2 lines of total paid amount including GST and total amount of GST paid.

Example

Input:
2
4
MeksisPrepaid 1 30.00 SR
JatiRice 1 32.00 ZR
RybenaJuice 2 18.00 SR
PeanutButter 5 4.50 SR
3
GardenihaBread 3 2.40 ZR
WaterSpinach 5 1.10 ZR
iPong6 1 2779.00 SR

Output:
Case #1:
Total Amount Include GST: 125.81
Total Amount GST Paid: 5.31
Case #2:
Total Amount Include GST: 2958.44
Total Amount GST Paid: 166.74

Added by:fifteen
Date:2016-05-09
Time limit:10s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C C++ 4.3.2 CPP14 JAVA
Resource:PCComp2015

hide comments
2021-09-25 15:02:58
how to change language
2021-06-12 03:27:01
Useful, practical exercise for beginners in programming stupidly wasted by language restrictions. Downvoting.
2021-02-13 05:54:46
why only 4 languages?
2018-12-27 08:48:36 Noszály Csaba
@author: what is the reason of language restriction?
2018-06-02 14:44:44
please provide python editor i have the solution
2017-07-05 16:06:02
Getting wrong answer here but works well in my system:/
2017-04-19 05:11:18
for anyone having issues re-read the output criteria!
2016-09-24 17:45:39
@xinnix
After use setprecision()
cout<<"Total Amount Include GST: "<<fixed<<setprecision(2)<<gst<<endl;
Show wrong answer....why?
2016-06-19 13:23:39
My code is working correctly on gcc but when i am submitting here it is displaying wrong answer.What should i do ?
2016-06-16 13:15:35
It works correctly in my local machine for the given test case, but here it shows wrong answer.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.