Read Three Different Types
Easyjava
Read an integer, a decimal number and a word (in that order), then print them in a formatted line.
Input: three whitespace-separated tokens — an int, a double, a word.
Output: one line: <word>: <int>, <double>
Example 1
Input
5 2.5 score
Output
score: 5, 2.5
- the double uses a dot as the decimal separator
Hint 1
Read each value as a token with sc.next() and convert it.
Hint 2
Assemble the output as word + ": " + n + ", " + d.
Scanner can read tokens of different kinds one after another. Convert each with the matching parse method, then build the output string. The double 1.0 prints with its .0 preserved.