ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 06 May 2017 My Price 8.00

Prompt the user to enter a string of their choosing

Hey guys!!!!! Just looking for some help on this problem. This is for JAVA. 

 

Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1 pt) 

Ex:

Enter a sample text: We'll continue our quest in space.  There will be more shuttle flights and more shuttle crews and,  yes,  more volunteers, more civilians,  more teachers in space.  Nothing ends here;  our hopes and our journeys continue!

You entered: We'll continue our quest in space.  There will be more shuttle flights and more shuttle crews and,  yes,  more volunteers, more civilians,  more teachers in space.  Nothing ends here;  our hopes and our journeys continue!


(2) Implement a printMenu() method, which outputs a menu of user options for analyzing/editing the string, and returns the user's entered menu option. Each option is represented by a single character.

If an invalid character is entered, continue to prompt for a valid choice. Hint: Implement Quit before implementing other options. Call printMenu() in the main() method. Continue to call printMenu() until the user enters q to Quit. (3 pts) 

Ex:

MENU
c - Number of non-whitespace characters
w - Number of words
f - Find text
r - Replace all !'s
s - Shorten spaces
q - Quit

Choose an option: 


(3) Implement the getNumOfNonWSCharacters() method. getNumOfNonWSCharacters() has a string as a parameter and returns the number of characters in the string, excluding all whitespace. Call getNumOfNonWSCharacters() in the main() method. (4 pts) 

Ex:

Enter a sample text: We'll continue our quest in space.  There will be more shuttle flights and more shuttle crews and,  yes,  more volunteers, more civilians,  more teachers in space.  Nothing ends here;  our hopes and our journeys continue!

You entered: We'll continue our quest in space.  There will be more shuttle flights and more shuttle crews and,  yes,  more volunteers, more civilians,  more teachers in space.  Nothing ends here;  our hopes and our journeys continue!

MENU
c - Number of non-whitespace characters
w - Number of words
f - Find text
r - Replace all !'s
s - Shorten spaces
q - Quit

Choose an option: c
Number of non-whitespace characters: 181


(4) Implement the getNumOfWords() method. getNumOfWords() has a string as a parameter and returns the number of words in the string. Hint: Words end when a space is reached except for the last word in a sentence. Call getNumOfWords() in the main() method. (3 pts) 

Ex:

Number of words: 35


(5) Implement the findText() method, which has two strings as parameters. The first parameter is the text to be found in the user provided sample text, and the second parameter is the user provided sample text. The method returns the number of instances a word or phrase is found in the string. In the main() method, prompt the user for a word or phrase to be found and then call findText() in the main() method. (3 pts) 

Ex:

Enter a word or phrase to be found: more
"more" instances: 5


(6) Implement the replaceExclamation() method. replaceExclamation() has a string parameter and returns a string which replaces each '!' character in the string with a '.' character. replaceExclamation() DOES NOT output the string. Call replaceExclamation() in the main() method, and then output the edited string. (3 pts) 

Ex.

Edited text: We'll continue our quest in space.  There will be more shuttle flights and more shuttle crews and,  yes,  more volunteers, more civilians,  more teachers in space.  Nothing ends here;  our hopes and our journeys continue.


(7) Implement the shortenSpace() method. shortenSpace() has a string parameter and returns a string that replaces all sequences of 2 or more spaces with a single space. shortenSpace() DOES NOT output the string. Call shortenSpace() in the main() method, and then output the edited string. (3 pt) 

Ex:

Edited text: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue!

 

Answers

(11)
Status NEW Posted 06 May 2017 04:05 AM My Price 8.00

Pro-----------mpt----------- th-----------e u-----------ser----------- to----------- en-----------ter----------- a -----------str-----------ing----------- of----------- th-----------eir----------- ch-----------oos-----------ing-----------

Attachments

file 1520592372-Prompt the user to enter a string of their choosing.docx preview (714 words )
A-----------nsw-----------er ----------- im-----------por-----------t j-----------ava-----------.ut-----------il.-----------*; ----------- cl-----------ass----------- Ma-----------in{----------- p-----------ubl-----------ic -----------sta-----------tic----------- vo-----------id -----------mai-----------n(S-----------tri-----------ng[-----------] a-----------rgs-----------) {----------- S-----------can-----------ner----------- sc-----------nr -----------= n-----------ew -----------Sca-----------nne-----------r(S-----------yst-----------em.-----------in)-----------; -----------Str-----------ing----------- ma-----------inS-----------tri-----------ng -----------= i-----------npu-----------tSt-----------rin-----------g()-----------; -----------cha-----------r m-----------enu-----------Cho-----------ice----------- = -----------'?'-----------; -----------whi-----------le(-----------men-----------uCh-----------oic-----------e !-----------= '-----------q')-----------{ -----------men-----------uCh-----------oic-----------e =----------- pr-----------int-----------Men-----------u()-----------; -----------if(-----------men-----------uCh-----------oic-----------e =-----------= '-----------c')-----------{ -----------int----------- n -----------= g-----------etN-----------umO-----------fNo-----------nWS-----------Cha-----------rac-----------ter-----------s(m-----------ain-----------Str-----------ing-----------); ----------- } ----------- el-----------se -----------if(-----------men-----------uCh-----------oic-----------e =-----------= '-----------w')-----------{ -----------int----------- n -----------= g-----------etN-----------umO-----------fWo-----------rds-----------(ma-----------inS-----------tri-----------ng)-----------; -----------} -----------els-----------e i-----------f(m-----------enu-----------Cho-----------ice----------- ==----------- 'f-----------'){----------- S-----------yst-----------em.-----------out-----------.pr-----------int-----------(&q-----------uot-----------;En-----------ter-----------
Not Rated(0)