The writer is very fast, professional and responded to the review request fast also. Thank you.
Hello,
Can anyone help me? I am completely lost. and have 6 hours to complete this.
In this project, you will demonstrate your mastery of the following competency:
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:
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.
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.
Programming Languages Explanation
Consider the coding work you have completed for the grocery-tracking program. You will now take the time to think more deeply regarding how you were able to combine two different programming languages, C++ and Python, to create a complete program. The following should be completed as a written explanation.
#include <Python.h>
#include <iostream>
#include <Windows.h>
#include <cmath>
#include <string>
using namespace std;
/*
Description:
To call this function, simply pass the function name in Python that you wish to call.
Example:
callProcedure(“printsomething”);
Output:
Python will print on the screen: Hello from python!
Return:
None
*/
void CallProcedure(string pName)
{
char *procname = new char[pName.length() + 1];
std::strcpy(procname, pName.c_str());
Py_Initialize();
PyObject* my_module = PyImport_ImportModule(“PythonCode”);
PyErr_Print();
PyObject* my_function = PyObject_GetAttrString(my_module, procname);
PyObject* my_result = PyObject_CallObject(my_function, NULL);
Py_Finalize();
delete[] procname;
}
/*
Description:
To call this function, pass the name of the Python functino you wish to call and the string parameter you want to send
Example:
int x = callIntFunc(“PrintMe”,”Test”);
Output:
Python will print on the screen:
You sent me: Test
Return:
100 is returned to the C++
*/
int callIntFunc(string proc, string param)
{
char *procname = new char[proc.length() + 1];
std::strcpy(procname, proc.c_str());
char *paramval = new char[param.length() + 1];
std::strcpy(paramval, param.c_str());
PyObject *pName, *pModule, *pDict, *pFunc, *pValue = nullptr, *presult = nullptr;
// Initialize the Python Interpreter
Py_Initialize();
// Build the name object
pName = PyUnicode_FromString((char*)”PythonCode”);
// Load the module object
pModule = PyImport_Import(pName);
// pDict is a borrowed reference
pDict = PyModule_GetDict(pModule);
// pFunc is also a borrowed reference
pFunc = PyDict_GetItemString(pDict, procname);
if (PyCallable_Check(pFunc))
{
pValue = Py_BuildValue(“(z)”, paramval);
PyErr_Print();
presult = PyObject_CallObject(pFunc, pValue);
PyErr_Print();
}
else
{
PyErr_Print();
}
//printf(“Result is %dn”, _PyLong_AsInt(presult));
Py_DECREF(pValue);
// Clean up
Py_DECREF(pModule);
Py_DECREF(pName);
// Finish the Python Interpreter
Py_Finalize();
// clean
delete[] procname;
delete[] paramval;
return _PyLong_AsInt(presult);
}
/*
Description:
To call this function, pass the name of the Python functino you wish to call and the string parameter you want to send
Example:
int x = callIntFunc(“doublevalue”,5);
Return:
25 is returned to the C++
*/
int callIntFunc(string proc, int param)
{
char *procname = new char[proc.length() + 1];
std::strcpy(procname, proc.c_str());
PyObject *pName, *pModule, *pDict, *pFunc, *pValue = nullptr, *presult = nullptr;
// Initialize the Python Interpreter
Py_Initialize();
// Build the name object
pName = PyUnicode_FromString((char*)”PythonCode”);
// Load the module object
pModule = PyImport_Import(pName);
// pDict is a borrowed reference
pDict = PyModule_GetDict(pModule);
// pFunc is also a borrowed reference
pFunc = PyDict_GetItemString(pDict, procname);
if (PyCallable_Check(pFunc))
{
pValue = Py_BuildValue(“(i)”, param);
PyErr_Print();
presult = PyObject_CallObject(pFunc, pValue);
PyErr_Print();
}
else
{
PyErr_Print();
}
//printf(“Result is %dn”, _PyLong_AsInt(presult));
Py_DECREF(pValue);
// Clean up
Py_DECREF(pModule);
Py_DECREF(pName);
// Finish the Python Interpreter
Py_Finalize();
// clean
delete[] procname;
return _PyLong_AsInt(presult);
}
void main()
{
CallProcedure(“printsomething”);
cout << callIntFunc(“PrintMe”,”House”) << endl;
cout << callIntFunc(“SquareValue”, 2);
}
import re
import string
def printsomething():
print (“Hello from python!”)
def PrintMe(v):
print(“You sent me: ” + v)
return 100;
def SquareValue(v):
return v * V
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more