Java Bootcamp – Workbooks and Challenges
)}

Javapedia

In this section's final project, you're the editor for Javapedia.

 

Javapedia is a free encyclopedia that anyone can edit. As a world-renowned editor, your task is to submit information about famous historical figures.

Then, Javapedia will print the content from its "database" (in our case, a 2D array)

Javapedia also lets the user search popular figures by name:

**********Javapedia**********
How many historical figures will you register?
2

        Figure: 1
         - Name: Marco Polo
         - Date of birth: 08/01/1324
         - Occupation: Merchant

        Figure: 2
         - Name: Shakespeare
         - Date of birth: 26/03/1564
         - Occupation: Playwright

These are the values you stored:
        Marco Polo 08/01/1324 Merchant
        Shakespeare 26/03/1564 Playwright

Who do you want information on? Marco Polo

        Name: Marco Polo
        Date of birth: 08/01/1324
        Occupation: Merchant

Launch the workbook

First, launch the workbook from Visual Studio Code.

From Java Bootcamp Resources -> Module 2 -> 6. Array, open Javapedia.

Task 1

Ask the user: How many historical figures will you register?. Store the value in an int variable.

Task 2

Make a 2D array named: database. The data we're going to submit will take the form of a table.

So, our array must have as many rows as there are historical figures. Each row also needs 3 values.

Don't populate the array yet. Leave that for task 3.

Task 3

Create a for loop that runs through every row in the database. The user needs to submit three values per row.

As the user submits each value, you need to store it in the appropriate row. While doing this task, be careful of the nextLine pitfall (see cheat sheet).

Task 4

Print the contents of database. Create a function called print2DArray.

/** * Function name: print2DArray * @param array (String[][]) * * Inside the function * 1. print the database * - a tab of space precedes each row. * - each value in database has one space from the other value. */

Inside the function:

  • add a tab of space before each row.

  • add a space after printing each value.

Once you finish writing the function, use it to print database:

Task 5

The final task is to let the user search the database by name. If the search matches a name in database, print that row's information.

Final Output:

**********Javapedia**********
How many historical figures will you register?2

        Figure: 1
         - Name: Marco Polo
         - Date of birth: 08/01/1324
         - Occupation: Merchant

        Figure: 2
         - Name: Shakespeare
         - Date of birth: 26/03/1564
         - Occupation: Playwright

These are the values you stored:
        Marco Polo 08/01/1324 Merchant
        Shakespeare 26/03/1564 Playwright

Who do you want information on? Marco Polo

        Name: Marco Polo
        Date of birth: 08/01/1324
        Occupation: Merchant

When printing the information, add a tab of space before each line.

Good luck!

Feedback Summary
4.8
39 students
5

92%
4

3%
3

0%
2

0%
1

5%
Written Reviews
There are no written reviews yet.