Name Then Age
Mediumjava
Read a name on the first line and an age on the second line, then print them together.
Input: line 1 is a name (may contain spaces); line 2 is an integer age.
Output: one line: <name> (<age>)
Example 1
Input
Aditi Rao 21
Output
Aditi Rao (21)
- 1 <= name length <= 40
- 0 <= age <= 150
Hint 1
Read the name with nextLine() so spaces are kept.
Hint 2
Read the age line and convert it with Integer.parseInt to avoid the nextInt/nextLine pitfall.
Reading both values as lines (and parsing the age yourself) sidesteps the classic bug where a leftover newline from nextInt() makes the following nextLine() return an empty string.