Assign309SalesTax

.py
# ***************************************************************************** # Assign3_09_Sales_Tax.py # ***************************************************************************** # A retail company must file a monthly sales tax report listing the total sales # for the month, and the amount of state and county tax collected. The state # sales tax rate is 5 percent and the county sales tax rate is 2.5 percent. # Write a program that asks the user to enter the total sales for the month. # From this figure, the application should calculate and display the following: # * The amount of county sales tax # * The amount of state sales tax # * The total sales tax (county plus state) # ***************************************************************************** # Note: While there are a number of ways to modularize this program, you must # use the following approach: # 1. Design calc_state_tax(t_sales) function that accepts the total_sales as # an argument and returns two values, the county and state sales tax. The # function must use c_tax and s_tax local variables, as well as # COUNTY_TAX_RATE and STATE_TAX_RATE global constants. # 2. Design print_tax(tax_type, tax_amt) function that accepts a string # tax_type and the actual tax_amount and prints the result in the following # format: "The amount of type_tax is $tax_amt". # 3. The main program must receive the tax values in county_tax and state_tax # variables, calculate the total_sales_tax and display all three (3) by # calling the print_tax function 3 times with appropriate parameters. # ***************************************************************************** # Test: Your input and output should look like this: # Enter total sales for the month: 100000 # The amount of county sales tax is $2,500.00 # The amount of state sales tax is $5,000.00 # The amount of total sales tax is $7,500.00 # ***************************************************************************** COUNTY_TAX_RATE = 0.025 STATE_TAX_RATE = 0.05 # Main function def main(): # Use the input() function to get the total sales total_sales = float(input('Enter total sales for the month: ')) # Call the calc_sales_tax function passing the total sales and # returning the county and state sales tax county_tax, state_tax = calc_sales_tax(total_sales) # Calculate the total monthly sales tax total_sales_tax = county_tax + state_tax # Display the appropriately formatted results using print_tax 3 times print_tax('county sales tax', county_tax) print_tax('state sales tax', state_tax) print_tax('total sales tax', total_sales_tax) # Multi-parameter function returning multiple values def calc_sales_tax(t_sales): # Calculate the county and state taxes c_tax = t_sales * COUNTY_TAX_RATE s_tax = t_sales * STATE_TAX_RATE # Return the county and state taxes return c_tax, s_tax
# Multi-parameter function not returning values, but using a # single print statement instead def print_tax(tax_type, tax_amt): print(f'The amount of {tax_type} is ${tax_amt:.2f}') # Call the main main()
Uploaded by DeanExploration18688 on coursehero.com