LaraBaltazarPA1

docx

School

Washington State University *

*We aren’t endorsed by this school

Course

325

Subject

Computer Science

Date

Apr 3, 2024

Type

docx

Pages

3

Uploaded by JusticeCrab4670

Report
Lara Baltazar Programming Assignment 1 Chapter 2, Programming Exercise 6: Sales Tax Due September 3, 2023 at 6:00pm Description of the assignment: Create a program that calculates the total sale amount using the original purchase amount entered by the user, the state sales tax rate and the county sales tax rate. The program should also display the sales tax and county sales tax as separate amounts before showing the grand total. Program design: Chapter 2, Programming Exercise 6. Sales Tax Write a program that will ask the user to enter the amount of a purchase. The program should then compute the state and county sales tax. Assume the state sales tax is 5 percent and the county sales tax is 2.5 percent. The program should display the amount of the purchase, the state sales tax, the county sales tax, the total sales tax, and the total of the sale (which is the sum of the amount of purchase plus the total sales tax). Hint: Use the value 0.025 to represent 2.5 percent, and 0.05 to represent 5 percent Pseudocode: Get the purchase amount from the user. Calculate the total sale using the state and county sales tax rate using the following formula: (Purchase amount * state sales tax rate) + (purchase amount * county sales tax rate) + purchase amount. Display the total sale. Python program code: #Get purchase amount purchaseAmount = float(input("Enter the amount of a purchase:")) #Assign value state sales tax percentage Statesalestaxpercentage = 0.05 #Assign value county sales tax percentage countysalestaxpercentage = 0.025 #Calculate state sales tax
statesalestax = purchaseAmount * Statesalestaxpercentage #Calculate county sales tax countysalestax = purchaseAmount * countysalestaxpercentage #Calculate total sales tax Totalsalestax = statesalestax + countysalestax #Calculate total sale Totalsale = purchaseAmount + Totalsalestax #Display required output print("The amount of the purchase:",purchaseAmount) print("The state sales tax:",statesalestax) print("The county sales tax:",countysalestax) print("The total sales tax:",Totalsalestax) print("The total of the sale:",Totalsale)
Program input/output: Any errors encountered and how they were diagnosed/resolved: Basically, I initially forgot to use the float command for inputting the purchase amount. As a result, the program couldn’t do any calculations for non-integer type data. Applied learning with business context/takeaways: This programming assignment taught me how to: 1. Assign variables 2. Use the define (#) the describe each line of code 3. Convert numeric data types using the float function 4. Use input command for user-created data This program would be useful in a situation in which I would need to calculate a business’s expenses, allowing me to skip past menial repetitive calculations.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help