Starting Out with C++: Early Objects (9th Edition)
Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
Question
Book Icon
Chapter 12, Problem 1PC
Program Plan Intro

Word Counter

Program Plan:

  • Include the required header files to the program.
  • Define function prototype which is used in the program.
  • Define the “main()” function.
    • Declare the required variables.
    • Get the input c-string from the user and call the function “word_count”.
    • Print the c-string words count.
    • Get the input string object from the user and call the function “word_count”.
    • Print the string object words count.
  • Define the “word_count” function.
    • Declare the variable.
    • The “while” loop is used to count the number of words in that string.
      • The “while” loop is used to ignore the whitespaces.
      • The “if” condition is used to count the words.
      • The “while” loop is used to move to next word.
    • Finally return the words count to the main function.
  • Define the “word_count” function.
    • Declare the variable.
    • Get the length of the string.
    • The “for” loop is used to count the number of words in that string object.
      • The “if” condition is used to ignore the whitespaces. Otherwise it is used count the words.
      • The “if” condition is used to determine the words.
    • Finally return the words count to the main function.

Blurred answer
Students have asked these similar questions
Exercise 1: Word Separator Write a program that accepts as input a sentence in which all of the words are run together, but the first character of each word is uppercase. Convert the sentence to a string in which the words are separated by spaces and only the first word starts with an uppercase letter. For example the string StopAndSmellTheRoses. would be converted to “Stop and smell the roses.” Exercise 2: replaceSubstring Function Write a function named replaceSubstring. The function should accept three string object arguments. Let’s call them string1, string2, and string3. It should search string1 for all occurrences of string2. When it finds an occurrence of string2, it should replace it with string3. For example, suppose the three arguments have the following values:   string1: “the dog jumped over the fence” string2: “the” string3: “that”   With these three arguments, the function would return a string object with the value “that dog jumped over that fence.” Demonstrate the…
10.17: Morse Code Converter C++Morse code is a code where each letter of the English alphabet, each digit, and various punctuation characters are represented by a series of dots and dashes. Table 10-8 from the textbook shows part of the code.   Write a program that asks the user to enter a string, and then converts that string to Morse code. Note that Morse code represents both upper and lower case letters so that both 'A' and 'a' will be converted to ".-".   Input Validation.None. Instructor Notes: Note: You can use the Morse table in the book or this site (space isn't listed, but it is just mapped to a space). You will most certainly need to create two parallel arrays to map the characters to the Morse code strings.
(String Matching): Write a program to use Horspool’s Algorithm to find the pattern in the string.   You can define two variables called Text and Pattern. Please display shift table for that pattern and display the shift value for each step. If not match, display a message “Unsuccessful Search”. If match, display the index. For example, If Text =“BARD LOVED BANANAS” and Pattern=”BAOBAB”. The result will be: Shift Table: A=1, B=2, O=3, other=6 Shift 6, shift 2, shift 6, pattern not found   If Text=”BARD LOVED BABAOBABANAS” and Pattern=”BAOBAB”. The result will be: Shift Table: A=1, B=2, O=3, other=6 Shift 6, shift 2, shift 2, shift 3, pattern found at position 13 Please let me know the solution in Java which gives exact mentioned outputs in question

Chapter 12 Solutions

Starting Out with C++: Early Objects (9th Edition)

Ch. 12.3 - Prob. 12.11CPCh. 12.3 - Prob. 12.12CPCh. 12.4 - What is the output of the following program?...Ch. 12 - A(n)___________is represented in memory as an...Ch. 12 - The____________ statement is required before the...Ch. 12 - A(n)____________is written in your program as a...Ch. 12 - Prob. 4RQECh. 12 - The______________ is used to mark the end of a...Ch. 12 - Prob. 6RQECh. 12 - Prob. 7RQECh. 12 - Prob. 8RQECh. 12 - Prob. 9RQECh. 12 - Prob. 10RQECh. 12 - Prob. 11RQECh. 12 - Prob. 12RQECh. 12 - Prob. 13RQECh. 12 - Prob. 14RQECh. 12 - Prob. 15RQECh. 12 - Prob. 16RQECh. 12 - Prob. 17RQECh. 12 - Prob. 18RQECh. 12 - Write a function whose prototype is char...Ch. 12 - #inc1ude iostream using namespace std; int main()...Ch. 12 - #include iostream using namespace std; int main()...Ch. 12 - #include iostream using namespace std; int main()...Ch. 12 - #inc1ude iostream #inc1ude string using namespace...Ch. 12 - #inc1ude iostream #inc1ude cstring using namespace...Ch. 12 - #inc1ude iostream using namespace std; int main()...Ch. 12 - #inc1ude iostream #inc1ude string using namespace...Ch. 12 - #include iostream #inc1ude cstring using namespace...Ch. 12 - #include iostre4m #inc1ude cstring using namespace...Ch. 12 - Each of the following programs or program segments...Ch. 12 - Soft Skills 30. You are a member of a...Ch. 12 - Prob. 1PCCh. 12 - Prob. 2PCCh. 12 - Prob. 3PCCh. 12 - Prob. 4PCCh. 12 - Name Arranger Write a program that asks for the...Ch. 12 - Prob. 6PCCh. 12 - Prob. 7PCCh. 12 - Prob. 8PCCh. 12 - Prob. 9PCCh. 12 - Password Verifier Imagine you are developing a...Ch. 12 - Prob. 11PCCh. 12 - Check Writer Write a program that displays a...Ch. 12 - Prob. 13PCCh. 12 - Dollar Amount Formatter Modify Program 12-13 by...Ch. 12 - Word Separator Write a program that accepts as...Ch. 12 - Prob. 16PCCh. 12 - I before e except after c A friend of yours who is...Ch. 12 - User Name Write a program that queries its...Ch. 12 - String Splitter Write a function vectorstring...Ch. 12 - Palindromic Numbers A palindromic number is a...
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning