(1) Prompt the user to enter a string of their choosing. Output the string. (1 pt)
Ex:
Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have to fear is fear itself.
(2) Complete the getNumOfCharacters() method, which returns the number of characters in the user's string. We encourage you to use a for loop in this function. (2 pts)
(3) In main(), call the getNumOfCharacters() method and then output the returned result. (1 pt)
(4) Implement the outputWithoutWhitespace() method, which outputs the string's characters except for whitespace (spaces, tabs). Note: A tab is '\t'. Call the outputWithoutWhitespace() method in main(). (2 pts)
Ex:
Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have to fear is fear itself. Number of characters: 46 String with no whitespace: Theonlythingwehavetofearisfearitself.
import java.util.Scanner; public class TextAnalyzer { public static int getNumOfCharacters(final String usrStr) { int numChar = 0; int i; for (i = 0; i < usrStr.length(); i++) { numChar++; } return numChar; } public static String outputWithoutWhitespace(String usrStr) { String noSpaceStr = usrStr.replaceAll(" ", ""); return noSpaceStr; } public static void main(String[] args) { Scanner scnr = new Scanner(System.in); String inputString; int numChar; String noSpaceStr; System.out.println("Enter a sentence or phrase:"); inputString = scnr.nextLine(); numChar = getNumOfCharacters(inputString); noSpaceStr = outputWithoutWhitespace(inputString); System.out.println("\nYou entered: " + inputString); System.out.println("\nNumber of characters: " + numChar); System.out.println("String with no whitespace: "+ noSpaceStr); } }
6.17.1 Lab #5 - Chapter 6 Text analyzer & modifier (C) (1) Prompt the user to enter a string of their choosing. Output the string. (1 pt) Ex: Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have to fear is fear itself. (2) Complete the GetNumOfCharacters() function, which returns the number of characters in the user's string. We encourage you to use a for loop in this...
This program should be run on Visual Studio. Please use printf and scanf as input and output. Thank you 6.11 Lab Exercise Ch.6a: Functions: String analyzer Create and debug this program in Visual Studio. Upload your Source.cpp file for testing (1) Prompt the user to enter a string of their choosing. Output the string. (1 pt) Ex: ics Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have...
7.17 LAB*: Program: Authoring assistant(1) 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....
(1) 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...
C++ (1) Prompt the user to enter a string of their choosing (Hint: you will need to call the getline() function to read a string consisting of white spaces.) 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!...
C++ please! (1) Prompt the user to enter the name of the input file. The file will contain a text on a single line. Store the text in a string. Output the string. Ex: Enter file name: input1.txt File content: 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() function,...
C++ A Program for Examining String (1) Ask the customer to type any string they like and then print it to the console. Example: Type a sentence: The CIS161 Computer Science II course is so much fun! You typed: The CIS161 Computer Science II course is so much fun! (2) Write the remaining code for the CountOfLetters() function, which returns the number of characters in the string that was entered. To get full credit for this question, this should be...
Security is an important feature of information systems. Often, text is encrypted before being sent, and then decrypted upon receipt. We want to build a class (or several classes) encapsulating the concept of encryption. You will need to test that class with a client program where the main method is located. For this project, encrypting consists of translating each character into another character. For instance, if we consider the English alphabet, including characters a through z, each character is randomly...
i need help getting this program running Pearson Sign in Mail - Josue Velazq... CSC 15 Chapter 4 lab This lab has two different problems. In this lab you are going to provide different options for the user to choose from Your program must provide the exact same output provided including "a" or "an". Requirements: You must use good style: meaningful variable names and good, consistent indentation All the I/O input/output) must be done in the run method. In addition...