01. Pointers and References – Homework Exercises
Write C++ code for solving the tasks on the following pages.
Code should compile under the C++03 or the C++11 standard.
Submit your solutions here: https://judge.softuni.bg/Contests/1150/01-Pointers-and-References-Homework
Any code files that are part of the task are provided under the folder Skeleton.
Please follow the exact instructions on uploading the solutions for each task.
Task 4 – Profits
You are given program in an ProfitsMain.cpp, as well as a Company.h and ProfitCalculator.h file, that read info about companies – name, id, revenue and costs, followed by info about profit calculations per company – company id followed by a tax percentage – and generates a report with the profit for each company in the input.
The report must contain exactly as many lines as there are companies, and each line should contain the name of the company on that line in the input, followed by a space, a '=', another space, and an integer value representing the profits of the company, e.g. a line of the output for a company called TheCompany with a profit of 42000 should look like this:
TheCompany = 42000
To generate the report, ProfitsMain.cpp uses a function named getProfitReport from a file named ProfitReport.h. The getProfitReport function receives 3 parameters:
A pointer to the first company in an array of companies
A pointer to the last company (inclusive) in an array of companies
An std::map, which maps company ids to ProfitCalculators
The getProfitReport should use the appropriate ProfitCalculator from the map (i.e. the ProfitCalculator in the entry with a key matching the id of the company) to calculate each company’s profit.
The getProfitReport returns a string, containing the report for the provided companies, calculated through the provided ProfitCalculators, as described above.
Your task is to study the code in ProfitsMain.cpp, then create a file called ProfitReport.h (which ProfitsMain.cpp includes) containing the definition of the getProfitReport function, written in such a way that ProfitsMain.cpp compiles successfully and works as described above.
След, много неуспешни опити, моля някой за съвет как да върна с getProfitReport, тази информация, да кажем че оппечатвам името на "компанията и = " в самата функция, как да върна печалбата, за всяка компания? Референция няма да ми помогне.
Разбира се моят ProfitReport.h, не е верен, много се помъчих, моля знаещите за подсказка! Аз не мога да се справя, без помощ!
ProfitReport.h - https://pastebin.com/5X18x5ZQ
Company.h - https://pastebin.com/sg9znX3U
ProfitsMain.cpp - https://pastebin.com/x3JhFfig
ProfitCalculator.h - https://pastebin.com/cVb1Gfb7
acme 424242420 : 43000 1000
softuni_foundation 20140414 : 0 0
itjoro 878968302 : 100 25
acme = 37800
softuni_foundation = 0
itjoro = 75