127k views
0 votes
You are doing a fantastic job at Chada Tech in your new role as a junior developer, and you exceeded expectations in your last assignment for Airgead Banking. Since your team is impressed with your work, they have given you another, more complex assignment. Some of the code for this project has already been completed by a senior developer on your team. Because this work will require you to use both C++ and Python, the senior developer has given you the code to begin linking between C++ and Python. Your task is to build an item-tracking program for the Corner Grocer, which should incorporate all of their requested functionality.

The Corner Grocer needs a program that analyzes the text records they generate throughout the day. These records list items purchased in chronological order from the time the store opens to the time it closes. They are interested in rearranging their produce section and need to know how often items are purchased so they can create the most effective layout for their customers. The program that the Corner Grocer is asking you to create should address the following three requirements for a given text-based input file that contains a list of purchased items for a single day:
Produce a list of all items purchased in a given day along with the number of times each item was purchased.
Produce a number representing how many times a specific item was purchased in a given day.
Produce 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.
As you complete this work, your manager at Chada Tech is interested to see your thought process regarding how you use the different programming languages, C++ and Python. To help explain your rationale, you will also complete a written explanation of your code’s design and functionality.
Directions
One of Python's strengths is its ability to search through text and process large amounts of data, so that programming language will be used to manage internal functions of the program you create. Alternatively, C++ will be used to interface with users who are interested in using the prototype tracking program.
Grocery Tracking Program
Begin with a Visual Studio project file that has been set up correctly to work with both C++ and Python, as you have done in a previous module. Remember to be sure you are working in Release mode, rather than Debug mode. Then add the CS210_Starter_CPP_Code and CS210_Starter_PY_Code files, linked in the Supporting Materials section, to their appropriate tabs within the project file so that C++ and Python will be able to effectively communicate with one another. After you have begun to code, you will also wish to access the CS210_Project_Three_Input_File, linked in the Supporting Materials section, to check the functionality and output of your work.
As you work, continue checking your code’s syntax to ensure your code will run. Note that when you compile your code, you will be able to tell if this is successful overall because it will produce an error message for any issues regarding syntax. Some common syntax errors are missing a semicolon, calling a function that does not exist, not closing an open bracket, or using double quotes and not closing them in a string, among others.
Create code to determine the number of times each individual item appears. Here you will be addressing the first requirement from the scenario to produce a list of all items purchased in a given day along with the number of times each item was purchased. Note that each grocery item is represented by a word in the input file. Reference the following to help guide how you can break down the coding work.
Write C++ code for when a user selects option 1 from the menu. Select and apply a C++ function to call the appropriate Python function, which will display the number of times each item (or word) appears.
Write Python code to calculate the frequency of every word that appears from the input file. It is recommended that you build off the code you have already been given for this work.
Use Python to display the final result of items and their corresponding numeric value on the screen.

User Arias
by
7.1k points

1 Answer

7 votes

Answer: The answer to this question involves writing code in both C++ and Python

Step-by-step explanation:

The answer to this question involves writing code in both C++ and Python to create an item-tracking program for the Corner Grocer which meets the requirements from the scenario.

In C++, the code should begin with a Visual Studio project file that has been correctly set up to work with both C++ and Python. The CS210_Starter_CPP_Code and CS210_Starter_PY_Code files should be added to their respective tabs in the project file.

The code should then create a menu which allows the user to select option 1. This should prompt a C++ function to call the appropriate Python function which will display the number of times each item appears.

In Python, the code should calculate the frequency of every word that appears from the input file. This can be done by using a loop to iterate through the file and count the number of times each item appears. The code should then use the print() function to display the final result on the screen.

Finally, the user should also include a written explanation of the code's design and functionality. This should include details on how the different programming languages, C++ and Python, are being used and how they are linked together to create the item-tracking program.

User Hamza Hasan
by
7.4k points