Skip to content

A grocery store application that integrates C++ and Python to display sales.

Notifications You must be signed in to change notification settings

paul4oliver/Integration-And-Inventory

Repository files navigation

Grocery-Tracking-Program

This application is desgined for a grocery store and uses both Python and C++ to demonstrate how to integrate two programming languages with an input file.

Using C++, Menu is displayed with 4 options.

Option 1: Python function called and displays every item name (once) and numeric frequecny based on input file.

Option 2: C++ code prompts person for specific item to look up on input file. Item is passed as parameter to python function that displays specific item name and numeric frequency based on input file.

Option 3: Python function reads input file and creates a file, which contains the words and their frequencies. Also, produces a text-based histogram listing all items purchased in a given day, along with a representation of the number of times each item was purchased.

Option 4: Exit program. Goodbye message is displayed to confirm exit of application.

Paul Kenaga- CS 210 Programming Languages- Southern New Hampshire University- June 17, 2021-

Programming Languages Explanation

The benefits of using C++ in a coding project are performance and user experience. The C++ code in project 3 focused on the user interface and receiving user input. While I have not yet used colors in any code I have done so far, C++ allowed me to create a border and organize the output in a clean, professional way. Functions, like setfill(), made formatting text, characters, and white space easier to construct and reuse. C++ also does well with exception handling which makes programs run smoother when an error occurs. The biggest drawback of using C++ in a coding project is syntax. C++ code is more difficult to understand and requires more discipline to ensure a semicolon ends a line. This creates more room for programming errors. C++ also requires more line of code to execute instructions which can impact code management (Alomari, Halimi, Sivaprasad, & Pandit, 2015). Variables also need to be declared which is more work, however it does improve transparency.

The benefits of using Python in a coding project is simplicity and easier to understand code. Writing the functions for Project 3 required considerably fewer lines than it would have if it had been completed in another language. There were no semicolons and variables did not need to be declared. Python supports a built-in library, “re”, that allows programmers to deal with regular expressions. Programmers can identify patterns in strings and replace text (Sharma, 2020). Python is able to work through large amounts of data because of structures like lists, dictionaries, and sets and because of collections like counter. Python is also not platform dependent which makes the project code easier to share with others. The low-level syntax and performance from built-in features make Python efficient for working with big data (Rose, 2019). A drawback from using Python in a coding project is the possibility of error coding when toggling between languages due to confusion.

Two or more coding languages can effectively be combined in a project to improve and separate functionality. During Project 3, Python code was used for the sole purpose of defining functions that were called in the C++ code. Keeping this code separate makes it easier for future modifications to take place. Meanwhile, the C++ code focused on receiving user input, calling functions, and displaying information. Dividing the programs functionality between two languages allows the programmer to take advantage of the strengths of each respective language. Python’s simple, minimal code made the construction of functions easier to write and read while C++’s input validation ensured smooth running. Both languages function well together, but C++ requires a lot of code to establish the connection. I think Java could be added as a third language if functions with high-level math were included. It could make calculations easier to compute. If the grocery corner wanted to expand the program functionality to include some revenue statistic or cost-related figure, Java could be used to define those mathematical function. Since Java is platform-independent, no changes would need to be made to the math in functions if used on different machines. This would make it more efficient in terms of portability.

References Alomari, Z., Halimi, O. E., Sivaprasad, K., & Pandit, C. (2015). Comparative Studies of Six Programming Languages.

Rose, S. (2019, December 27). Why is Python Programming a perfect fit for Big Data? Medium. https://towardsdatascience.com/why-is-python-programming-a-perfect-fit-for-big-data-5ac54ee8f95e

Sharma, V. (2020, July 13). Understanding Regular Expressions in Python. Medium. https://medium.com/swlh/understanding-regular-expressions-in-python-21410c64a6f2

About

A grocery store application that integrates C++ and Python to display sales.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published