Category: Java

Write a single statement that will print the message “first is ” followed by the value of first, and then a space, followed by “second = “, followed by the value of second.

Write a single statement that will print the message “first is ” followed by the value of first, and then a space, followed by “second = “, followed by the value of second.

LANGUAGE: Java CHALLENGE: Write a single statement that will print the message “first is ” followed by the value of first, and then a space, followed by “second = “, followed by the value of second. Print everything on one line and go to a new line after printing. Assume that first has already been declared […]

Read More

Consider this data sequence: “fish bird reptile reptile bird bird bird mammal fish”.

1
Consider this data sequence: “fish bird reptile reptile bird bird bird mammal fish”.

LANGUAGE: Java CHALLENGE: Consider this data sequence: “fish bird reptile reptile bird bird bird mammal fish”. Let’s define a SINGLETON to be a data element that is not repeated immediately before or after itself in the sequence. So, here there are four SINGLETONs (the first appearance of “fish”, the first appearance of “bird”, “mammal”, and the […]

Read More

Write a loop that reads strings from standard input where the string is either “land”, “air”, or “water”.

Write a loop that reads strings from standard input where the string is either “land”, “air”, or “water”.

LANGUAGE: Java CHALLENGE: Write a loop that reads strings from standard input where the string is either “land”, “air”, or “water”. The loop terminates when “xxxxx” (five x characters ) is read in. Other strings are ignored. After the loop, your code should print out 3 lines: the first consisting of the string “land:” followed by […]

Read More