Question: Please check the java project and correct it for me , thanks! * The program reads some text and convert the emoji letters to emojis.

Please check the java project and correct it for me,thanks!
* The program reads some text and convert the emoji letters to emojis.
*
* For each character in the text, do the following:
* If c equals to 'h' or 'H', change it to a happy emoji
* If c equals to 'a' or 'A', change it to an angry emoji
* If c equals to 's' or 'S', change it to a sad emoji
* Otherwise, keep it unchanged
*/
import java.util.Scanner;
public class AsciiToEmoji {
public static void main(String[] args){
// Prepare a scanner for user input handling
Scanner scanner = new Scanner(System.in);
// The input line
String line ="";
// Keep asking for the input until it is equal to "bye"
do {
System.out.print("Please enter a line of text (enter 'bye' to quit the program): ");
// Task 1.2: Read a line from the scanner object
line = scanner.nextLine();
// Task 2: Convert the emoji letters to emojis
if (!line.equals("bye")){
line = line.replace('h',':-)')
.replace('H',':-)')
.replace('a','*^*')
.replace('A','*^*')
.replace('s',':-(')
.replace('S',':-(');
System.out.println(line);
}
} while (!line.equals("bye"));
scanner.close();
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!