I need someone who knows C++ or at least can help me run through the logic involved in writing a program. I have a fair grasp of the syntax, this is for a class. I don't want it done for me just yet but I do need help cause I can't figure out how to go about this. I can pay Lg if you need it/want it.
I have to make a program that will determine how many nonblank characters are in an input sentence/paragraph supplied by the user. You will print the answer on the output screen for the user. The program should not end until the user ends it.
Also:
1. A paragraph is defined when the user presses the enter key. It can be a few words or a few sentences. Your program will begin to count the characters entered when the user presses the enter key. You test for the enter key as '\n' in the input stream.
2. You can use the Word Count feature in Word to test your program for accuracy.
3. To read in one character at a time, use the cin.get(variableName); function. There are additional get functions, such as getchar and gets, but get will give you what you need for this project.
4. When reading in the response to “Do you wish to continue?” Use the cin.get(variableName); to read in the first character and discard the rest (use cin.sync() ). See the C++ Notes on "Correcting Bad Input" in the Lessons tab in Angel for more information. Then test the one character for a y for yes or a n for no. If the user enters anything other than y or n (that includes both uppercase and lowercase), your program should respond with an invalid response. Do not let the program continue until the user responds correctly.
5. The three characters that should not be included in your count is the spacebar character, the tab character and the enter key character. The cin.get will read in a space, tab and the enter key, so you will need to test for these. If it is a space, tab or the enter key, do not count it in your counter. If it is not a space, tab nor the enter key, then increment your counter. To test for a space, use ' ' (single quotes with one space in between). To test for a tab key, use '\t'. To test for the enter key, use '\n'. (Actually the enter key character should be used as a sentinel value in your loop.)
6. A friendly reminder: The <clear screen> command is system("cls"); Please use it to make your program look nice.
Results 1 to 1 of 1
Thread: [Help] Char. Counter
- 24 Mar. 2010 12:28am #1
Global Moderator Literally Hitler
Morbidly Obese
Bird Jesus
- Age
- 34
- Join Date
- Nov. 2009
- Location
- The Land Of Ooo
- Posts
- 8,569
- Reputation
- 711
- LCash
- 200.00
[Help] Char. Counter