Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to add a check to this code for the first letter of each word in the input file. I need to check to

I need to add a check to this code for the first letter of each word in the input file. I need to check to make sure it is a letter, not a number or special character. The letter also must be lowercase. C++ code please. The code should then output is valid for words that fit that criteria and not valid for those that break the rules.

I have a few snippets that were commented out to help me.

Below is my current code:

#include  #include  #include  #include  using namespace std; void printReport(string userText, int vowels, int consonents, int specialCharacters); bool isVowel(char c); //bool isValid(string tester); int main() { ifstream inFile("data1.txt"); string s; char ch; int vowels = 0, consonents = 0, specialCharacters = 0, numbers = 0; while(inFile >> s) { vowels = consonents = specialCharacters = numbers = 0; for (int i = 0; i < static_cast(s.length()); i++) { ch = s[i]; if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) { if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U') { vowels += 1; } else { consonents += 1; } } else if (!(ch >= '0' && ch <= '9')) { specialCharacters += 1; } else if (ch >= '0' && ch <= '9') { numbers += 1; } } cout << s << " " <                        

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Logistics Lifeline Supply Chain Strategies

Authors: Ehsan Sheroy

1st Edition

7419377502, 978-7419377503

More Books

Students also viewed these Databases questions

Question

What is the preferred personality?

Answered: 1 week ago