please don't copy I need new code In this lab, we will practice: programming with C++ type string, its methods (built-in

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

please don't copy I need new code In this lab, we will practice: programming with C++ type string, its methods (built-in

Post by answerhappygod »

please don't copy I need new code
In this lab, we will practice: programming with C++ type string,its methods (built-in functions defined for C++ type string) andthe getline function.
Write a C++ program that counts and reports the number of wordsin a line of text entered by the user. Assume the text onlycontains words separated by single space.
Here are some example runs of the program:
Sample run 1:
Please enter a line of text: The baby smiles as soon as shewakes up.
There are 9 words in this sentence.
Sample run 2:
Please enter a line of text: Tom and Jerry are lovelycharacters.
There are 6 words in this sentence.
Sample run 3:
Please enter a line of text: The Labor day weekend passed soquickly.
There are 7 words in this sentence.
#include <iostream>using namespace std;
int main() {
return 0;}
Comments have been added to each group of logically relatedstatements, including each:
• Decision statement
• Loop statement
• Group of logically related statement
• User defined function
Variable:
• Meaningful names are used unless specified by the programdescription
• Variable naming convention is followed
• No global variable is used
Constants:
• Defined when appropriate
• Defined in the global declaration section
• Constant naming convention is followed
User defined functions:
• Defined when appropriate
• No function should have more than 25 lines of code (excludewhite lines and lines only containing curly brackets)
• Function naming convention is followed
Proper Indentation is used to make the program easier toread.
• All the decision statements are indented properly.
• All the loop statements are indented properly
• Body of the functions are indented
Blank lines are used in front of each block of logically relatedstatements
Program solves the assigned problem using methods described inprogram description.
Program compiles without errors.
Program executes without crashing.
Program produces the correct output when tested usingdifferent user input.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply