Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ PROGRAMMING QUESTION: Write a program that counts the number of upper case l

ID: 3877184 • Letter: C

Question

C++ PROGRAMMING QUESTION:

Write a program that counts the number of upper case letters, lower case letters, digits, spaces, and any other chars in a file. The program prompts the user to enter a file name (including file path). The program then opens the file and counts each of the before mentioned categories, then prints the output.

also; use the library #include<fstream>; create a variable type ifstream with the file name passed in as an argument; use getline(cin, string) function to read a line including whitespace

Example:

Enter a file: /Users/name/desktop/sample.txt

File contains -

Lowercase letters: 1000

Uppercase letters: 50

Digits: 18

Spaces: 400

Explanation / Answer

Hi,

Please find the complete program below with comments:

Console Output:

Enter a File:
F:c++Test eceipt.txt
File contains -
Lowercase letters:261
Uppercase letters:74
Digits:133
Spaces:94
Other letters:81

receipt.txt

7 Dec, 2017 7:46:12 PM jeanne Iced Coffee Single,Cinnamon,Cherry $5.5
7 Dec, 2017 7:54:24 PM cremer Latte Single,Sugar,Banana $4.0
7 Dec, 2017 7:55:24 PM gh Cappuccino Double,Banana,Cinnamon $5.5
7 Dec, 2017 8:08:08 PM grey Latte Single,Cinnamon,Banana $12.0
7 Dec, 2017 8:11:27 PM j Iced Coffee Single, $3.0
7 Dec, 2017 8:11:59 PM o Cappuccino Double,Cinnamon $9.0
7 Dec, 2017 8:12:48 PM k Iced Coffee Double, $3.5
7 Dec, 2017 8:13:13 PM l Cappuccino Single,Banana $7.5
7 Dec, 2017 8:15:38 PM h Iced Coffee Single,Cinnamon $7.0
7 Dec, 2017 8:16:55 PM h Iced Coffee Single,Cinnamon $4.0
7 Dec, 2017 8:17:05 PM i Iced Coffee Double,Almond $4.0

Let me know if you have any questions.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote