Question: FourWordPlay. You will ask the user for a string that contains four words. We will play with these works by using the following menu options.

FourWordPlay. You will ask the user for a string that contains four words. We will play with these works by using the following menu options. Consider y always as a constant. MUST BE IN JAVA

Which of the following would you like:

1. Check to see that there are really 4 words separated by spaces

2. List the four words on separate lines of output

3. List the four words on a single line separated by spaces, in reverse order (ex list the last one, then the 3rd, 2nd, and 1st

4. List the number of consonants in the original string (consider y as a vowel

5. List the original string in pig latin

6. To count the number of occurrences of a specific character in the string

7. Enter an new string

999. Quit the program

CHOICE:

--EXAMPLE OF CODE STRUCTURE-- (what I have so far)

public class FourWordPlay {

// create a String field named theString

private String theString;

// add the empty and full constructors

FourWordPlay(){

}

FourWordPlay(String ans){

ans = theString;

}

public boolean check(){

}

public void separateLines(){

for (int i = 0; i < theString.indexOf(getTheString()); i++) {

System.out.println(i);

}

}

public void backwards() {

for (int i = theString.indexOf(theString); i >0; i--) {

System.out.print(i);

}

}

public String pig() {

}

public int numCons(){

}

public int numTimes(char c){

}

// generate the getter and setter at the bottom of this file

public String getTheString() {

return theString;

}

public void setTheString(String theString) {

this.theString = theString;

}

}

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 Databases Questions!