Programming 1: My Favorite Program

Programming 1: My Favorite Program

After some convincing from my parents, sister, and our teacher, Mr.Sommerer, I decided to try out a programming class this year. It was a little funny how I got into it. My parents and sister had talked to me about the pros and cons of the class and how this is the only year I’d have the chance to take it, since it’s only there every other year. I was debating it, but knew I also needed to take a cooking class either this year or next. I had settled on the cooking class until about a day before the due date for our schedules. I received an email from Mr.Sommerer saying, “I can’t believe you’re taking Foods instead of Programming 1”. This is pretty much what convinced me to give it a shot. The class is a lot of work, a little frustrating, and time consuming, but I don’t regret joining. It’s a ton of fun and it’s very unique compared to any of my other classes.

My favorite program so far is our Coffee/Tea Shop program. Simply stated, this program acts as a calculator for a worker who’s taking orders of coffee and tea over the phone. The worker enters what they’re buying, how much of it they’d like, where they’re shipping it to, and what company they’d like it to be shipped through. The program is able to figure out the total cost of the order, state and shipping tax, plus the amount of time it’ll take to arrive, then nicely prints out all this information on a receipt. I loved this program mostly because it gave you the freedom to be creative with your menu, receipt, and responses to invalid inputs. For example, I named my shop the Mean Bean and had each type of coffee and tea nicknamed (“Love You So Matcha”, “All-Nighter”, “Microwaved Dirt”, and so on). 

The main challenge I had while writing this program was debugging. A couple of the mistakes were just spelling typos, which were normally easy for me to find, but some of the bugs were a lot more complex and took forever to fix. There really wasn’t a way to overcome this besides reading the information idle (what we program on) gives about the error and working at it.

def print_receipt(itemName, itemCost, tax, shippingCost, shippingMethod, shippingTime, totalCost, weight):

 “””Prints a receipt of the user’s order.”””

 #

 # Changes the totals into strings.

 #

 weight = str(weight)

 itemCost = str(itemCost)

 tax = str(tax)

 shippingCost = str(shippingCost)

 totalCost = str(totalCost)

 print(“””=============================================================================

                                Receipt

=============================================================================”””)

 print(itemName+” x “+weight+” lbs”)

 print(“Shipping method: “+shippingMethod)

 print()

 print(”   Item cost: $”+itemCost)

 print(”   Tax: $”+tax)

 print(“+  Shipping cost: $”+shippingCost)

 print(“————————————-“)

 print(“Total cost: $”+totalCost)

 print()

 print(“Your order should arrive “+shippingTime+”.”)

 print(“=============================================================================”)

This is the portion of my code that prints out the receipt. It takes the information from the functions that collect what the user puts in and organizes it all into an readable format. I picked to show this section because it’s one of the easier parts of the code to read. The words that are highlighted red are what’s printed, then everything in black are the variables that it’s taking and putting into the receipt. The black at the very top is telling it to take the numbers it found and turn them into words. Lastly, the green is what you’re telling it to do, and in this case it’s to print out whatever text is behind it onto the screen.

These pictures show a bit of my program running. It first prints out the instructions, then asks what you’re ordering and how much of it you’d like. You enter the number by whatever item you’d like and the amount, then it asks what you’d like to ship it through. The shipping costs per each choice is shown, so you can see the amount of time it takes to get to you and how much each costs. After entering the number by whichever company you’d like to ship the item through,  it asks what state the order is being shipped to, which tells it the state tax. Finally, the receipt is printed out and the program asks if you’d like to make another order. If you enter “yes” or “y”, it repeats, and if enter “no” or “n”, it says goodbye and ends the program.

Leave a Reply

Your email address will not be published. Required fields are marked *