Write a method named generateHashtag that accepts a Scanner object as its parameter – your program should continuously read phrase (a line of input - can contain spaces) using the nextLine() method of the Scanner class until the String read in equals “done” (ignoring case).
For each phrase entered, your method should print a hashtag (#) followed by the phrase with spaces removed and all letters lowercase.
import java.util.Scanner;
public class HashTags {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
generateHashtag(sc);
}
public static void generateHashtag(Scanner sc) {
String line=sc.nextLine();
while(!line.equals("done")) {
line = "#"+line.replaceAll(" ", "").toLowerCase();
System.out.println(line);
line = sc.nextLine();
}
}
}
NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.
I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME
Get Answers For Free
Most questions answered within 1 hours.