Question: PROBLEM 1: SALES TAX PYTHON Introduction: In this problem, you will input the two-character abbreviation for a Canadian province or territory and a sales amount.

PROBLEM 1: SALES TAX

PYTHON

Introduction:

In this problem, you will input the two-character abbreviation for a Canadian province or territory and a sales amount. You will then calculate the appropriate sales tax for that location.

In Canada, sales tax varies between provinces and territories. Some have a separate provincial sales tax (PST) and a federal sales tax (GST), while others have a harmonized sales tax (HST), which combines both.

The following sales tax table shows information from the Retail Council of Canada:

Table A: List of provinces and territories with taxes and abbreviations

Province/Territory Abbrev. PST GST HST
Alberta AB 5%
British Columbia BC 7% 5%
Manitoba MB 7% 5%
New Brunswick NB 15%
Newfoundland and Labrador NL 15%
Northwest Territories NT 5% 15% 0%
Nova Scotia NS 15%
Nunavut NU 5%
Ontario ON 13%
Prince Edward Island PE 15%
Quebec QC 9.975% 14.975% 5%
Saskatchewan SK 6% 5%
Yukon YT 5%

Note: There was a slight mistake with the Quebec PST value. The test cases actually use the total tax rate of 14.975% rather than the PST of 9.975%. So, use the 14.975% value instead for the PST in Quebec!

Note 2: Another mistake was found. The tax for Northwest Territories is 5% GST, not 15% HST. Sorry again.

Input:

The program must receive two lines of input:

Input the 2-character code (string) for the province or territory in which the sale was made and store it to a variable called provAbbrev. This will be the internationally approved alphabetic code found in the Abbrev column in the table in the introduction.

Input the sales amount (float) and store it to a variable called salesAmount.

Processing:

For this problem:

Assume the program will receive a valid province/territory code.

The code may be in uppercase, lowercase, or a mixture of the two. Your program must take this into account.

Calculate the PST, GST, and HST for the sales amount based on the province or territory in which the sale took place.

Store PST, GST, and HST to variables called PST, GST, and HST respectively.

If one of the taxes is not used in this province or territory, make sure it is set to 0.0.

Hint

This problem will require multiple branches/paths through the program.

OUTPUT:

Note

The output section of the program is already written for you. This description is here to explain what is happening in the given code. There is nothing for you to add or change in the output section. However, you really ought to review it as you will need to write similar output sections yourself later.

Output must be in the following form:

Sales: $xxx,xxx.xx PST: xxx,xxx.xx GST: xxx,xxx.xx HST: xxx,xxx.xx ------------------ Total: $xxx,xxx,xx 

Please note:

No amount in a test will be greater than 999,999.99.

All amounts must line up on the decimal place.

If an amount is in the thousands, a comma must be printed to separate thousands from hundreds.

Both Sales and Total must have a $; none of the taxes have a $.

The line of hyphens separating HST from Total is 18 characters long.

HINT: Review Formatted Output from the course notes to understand what the f-strings are doing in the code.

Examples

Input Output
AB 100.00 Sales: $ 100.00 PST: 0.00 GST: 5.00 HST: 0.00 ------------------ Total: $ 105.00
NS 100.00 Sales: $ 100.00 PST: 0.00 GST: 0.00 HST: 15.00 ------------------ Total: $ 115.00
nL 102230.99 Sales: $102,230.99 PST: 0.00 GST: 0.00 HST: 15,334.65 ------------------ Total: $117,565.64
qc 99999.99 Sales: $ 99,999.99 PST: 14,975.00 GST: 5,000.00 HST: 0.00 ------------------ Total: $119,974.99
Nu 29923.87 Sales: $ 29,923.87 PST: 0.00 GST: 1,496.19 HST: 0.00 ------------------ Total: $ 31,420.06

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!