Question

WORK AREA Goal: Practice using methods in the Character and String classes Assume a string str contains a list of words separated with semicolons. Print each word after replacing the substring xx with the letter a. Sample Output: Enter a string: hxxt,exxt,mxxp:xrxxy hat cat map xray SUBMIT 1 of 1: Sun Feb 18 2018 17:17:59 GMT-0500 (EST) 1 Type your solution here...
0 0
Add a comment Improve this question Transcribed image text
Answer #1

ReplaceX X.java:

import java.util.Scanner;

public class ReplaceXX {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        String str;
        System.out.print("Enter a string: ");
        str = scanner.next();
        String words[] = str.split(";");
        for(String word: words){
            System.out.println(word.replaceAll("xx","a"));
        }
    }
}

\color{red}\underline{Output:}

Enter a string: hxxt;cxxt;maxp: xrxxy hat cat map xray Process finished with exit code 0

Add a comment
Know the answer?
Add Answer to:
WORK AREA Goal: Practice using methods in the Character and String classes Assume a string str...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Overview: The goal of this assignment is to implement a simple spell checker using a hash...

    Overview: The goal of this assignment is to implement a simple spell checker using a hash table. You will be given the basic guidelines for your implementation, but other than that you are free to determine and implement the exact classes and methods that you might need. Your spell-checker will be reading from two input files. The first file is a dictionary containing one word per line. The program should read the dictionary and insert the words into a hash...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT