Java Bootcamp – Workbooks and Challenges

Workbook 2.5

From Java-Bootcamp-Resources -> Module 1 - Introduction to Java -> 2. Variables, open Workbook 2.5.


In this workbook, you're a new developer for JavaGram: Instagram for Java developers. Your job is to make the sign-up page for new users.

Careful from the nextLine() trap

Before you start this workbook, I need to warn you about the: "nextLine() trap".

  • nextLine() gets "skipped" if you put it ahead of nextInt() , nextDouble(), nextLong(). You can expect this behaviour when you try to pick up the username.

  • You will understand why this happens when we cover Delimiters in the next section (Booleans and Conditionals).

  • The solution is to add a throwaway nextLine() before the "real" nextLine().

Task 1: Ask the user questions

First, you will ask the user to enter:

  • their first name

  • their last name

  • their age

  • a username

  • their city

  • their country.

Your output should appear as follows:

Task 2: Print their information.

After the user enters their information, you'll print:

Thank you for joining JavaGram!

Then, display their information in a nice format:

If you want a nice format:

  1. Put a line of space between: "Thank you for joining Javagram " and " Here is the information you entered ". You can use the escape character \n.

  2. Put a tab of space before each piece of information. You can use the escape character \t.

Run your code.

Good Luck!

Feedback Summary
39 students





Written Reviews
There are no written reviews yet.