In this video, I'm going to go through tasks one to four.
The first task is to ask the user how many historical figures they'd like to register, so pick up the
number with scanned next and.
And that's pretty much it, the second task is to make a tutelary name database.
String.
Database.
Is equal to some number of rose.
And some number of columns, some number of elements, Perreault.
And now, since the data takes the form of a table in the array needs to have as many rows as there
are historical figures, it makes sense that however many figures the user decides to input, that's
going to determine the number of rows.
And if you look at the example output, we know that each row was going to have three elements of data.
Tasks threes to populate the 2D array with information.
So first I'm going to make a for loop that runs through every row in the database.
Each row contains three values, so during each one ask the user for three things their name, birthday
and occupation, basically just copy the print statements that I left for you.
And pick up each answer using next line.
Run the code so far.
And notice the bug, it's the classic scandal next line, Tropp.
Remember, that scandal next line gets wasted when it's ahead of a next into next long next doubler
next.
And the solution is to add a throwaway next line just before the real next line.
Run the code.
Everything should work properly now.
Here we enter the loop and it's asking me to enter information.
I'm just going to stop the output with control, see, and we'll come back to this.
All right, to the user is going to submit three values, Perreault As the user submits each value we
need to store them.
We're going to store the first value at index zero of Rahbi.
We can store the second value in index one of rowby.
And we can store the 3rd value in index two of RaouI.
Already, each passing the for loop goes through a row and for each row we're updating the elements
and indexes zero, one and two, let's run the code.
I'm going to input two historical figures.
They should create an array with two rows.
Our tutera is going to have a length of two, which means the for loop is going to run twice and during
each run we're populating one row in our two tutera.
A populate the first row with the name of Marco Polo.
I did a birth.
And Marco Polo was a merchant.
And notice that little space that we have between the submission and the next entry, that's because
we have a new line being printed after it goes through a row.
And now I can enter the information for the second row.
I'm going to say Shakespeare.
Date of birth, 26, 03, 15, 64.
And Shakespeare was a playwright.
OK, perfect, before we wrap up this task, we can have a little bit more fun in our loop.
Right before we enter the information for each historical figure, I'm going to print the figure number.
So here, I'll add another new line and a tab for aesthetic purposes, then we'll say figure Colen.
And instead of printing, I, I'm going to print I plus one.
Because I starts at zero and I don't want the order of each figure to start counting from zero, that'd
be kind of weird.
And also remember to put your arithmetic operations inside brackets when displaying them as part of
a string.
We talked about this all the way back in variables.
But anyways, let's run the code.
And everything looks pitch perfect, and when enter, the values are figure one.
And figurative.
So at this point, all of the information is inside the tutera.
The next step is to make a function that prints the contents of the array.
As always, it's going to be public static.
The function is void and takes one parameter, a string to Deira called array.
Now, the first instruction is to print the entire database and running through every value in a tiara
requires a nested loop.
So we're going to make an outer loop that runs through each arrow.
And an inner loop that runs through every string in that row.
And inside the inner loop, we're going to print an element in the array.
With their own Ze'evi.
And Jay is going to index every element in the current row I.
Before we finish coding the logic inside printed today, right, I'm going to call it.
Passing in our database is an argument because it's a good idea to keep testing the function as we update
it.
I'm going to put the same information as before.
And it looks like it prints every string on the same line.
So after each year, we need to add one line of space.
I'll run the code and fast forward this time around.
OK.
And now if you look back at the image from the instruction, it tells us that each row precedes a tub
of space and each string has one space from the other string.
So we're going to add a tub of space before printing each Urhobo of values.
And then I'm out of space after printing each value.
I'm going to rerun the code.
But the same information is before.
First, I'll fill the info for Marco Polo.
And Shakespeare.
And this looks perfect.
That is all for task for in part two of the solution, we're going to implement task number five.