Hello! In this video, I will present the solution for the exercise from C++ Primer Plus (Stephen Prata) textbook.
Part-5 Exercise-6
First I'll tell you what need to do in the exercise.
The program should take from the user the number of books sold for each month for three years.
At the end the program should give a message about how many books have all been sold.
In order to speed up the check, I left three months in each year.
First check that the program is working correctly.
I will enter data for the three months of 2017.
in January - 21
in February - 3
in March - 0
Let's move on to the next year:
in January - 23
in February - 50
in March - 3
Next Year,  January - 44
in February - 100
in March - 45
So we see...
Every year.
In the first year: 21, 3, 0
In the second year: 23, 50, 3
In the third year: 44, 100, 45
And here we see how many books were sold.
Now let's see the code.
At the beginning of the program, I call the "string" library, because I declare an array of type string.
A line "using namespace std" is needed in order to use "cout" (output) and "cin" (input). 
In the next line, I declare an array of string type of months.
The two variables "rowYears" and "colMonths" symbolize how many months and how many years I have in the program.
If I want to extend this array for 12 months, then I just change the value to 12.
Here I allocate dynamic memory for the matrix.
This matrix will store data on sales for each month for three years.
In the end, I will free up the memory that I have allocated for the matrix.
It can be seen here.
The program should receive data on sales for 3 years.
I decided to start from 2017.
To do this, I created an integer-type variable, called "year".
And I'm starting to receive data.
I go through all the fields, every field is a year.
The cycle does not end until 3 years pass.
This variable is a stop condition.
The external unit is responsible for the passage of the year.
The indoor unit is responsible for going through the months.
The user sees the year and month.
In response, the user enters the number of books sold.
Then, data from the user enters the dynamic matrix.
Then there is a transition to the next year (year++).
This code creates an indent in two lines to separate the input from the output of the matrix.
This part of the code provides the output of the matrix.
The matrix presents data on sales for all years and months.
After displaying all the data in the matrix,
the program calculate the amount of all sales.
Here I declare a variable to sum up the books sold for all months in three years.
The cycle "for" once again passes through all the years and months
and calculates inside the matrix.
The variable "sum" is constantly increasing throughout the calculation.
Then the amount is displayed.
Next, the memory allocated to the matrix is freed.
Let's see how the program works again ..
January 2017 - 38
February - 0
March - 999
Next year: 4, ..
34
99
Next year:
90
1
98
Let's look at the matrix ..
First year,
second year, 
third year.
At the end is the total number of sales.
Thank you for your attention goodbye.
