ASCII Art

Report a typo

Implement the asciiArt method that takes the list of strings, joins them into a single string, and adds the ( symbol at the beginning of the resulting string and ) symbol at the end of the resulting string.

Remember to use the collect operation to solve the problem.

You may find the Collectors.joining method particularly useful.

Sample Input 1:

ಠ _ ಠ

Sample Output 1:

(ಠ_ಠ)

Sample Input 2:

• _ •

Sample Output 2:

(•_•)
Write a program in Java 17
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

class Main {

/**
* Returns joined list elements with '(' for the prefix
* and ')' for the suffix.
*
* @param symbols the input list of String elements
* @return the result of joining
*/
public static String asciiArt(List<String> symbols) {
// write your code here
}

// Don't change the code below
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
List<String> symbols = Arrays.asList(scanner.nextLine().split("\\s+"));
System.out.println(asciiArt(symbols));
}
}
___

Create a free account to access the full topic