Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is all written in c++ Visual studio Count the number of occurrences of: if , else , while , case , and for within
- This is all written in c++ Visual studio
- Count the number of occurrences of: if, else, while, case, and for within a text file.
- When we grade, well use some sample .cpp from the class folder.
- You can assume your keywords are lower case because thats the way they would be in a .cpp.
- Count the total number of words in the file. Be careful not to add an extra word at the end of file.
- Use the string class for any text variables.
- Allow the user to enter the file name. If the open fails because they entered a bad name let them know and stop. (Please be kind to your end user.)
- Output your counts in a reasonably pretty way including telling the user the file name.
- Your main function can be no more than 15 lines long. Use functions instead. Dont cram to get to the 15 lines. Mine is 11 lines including the int main and the closing }.
- Use a structure to store your data.
- A total count of words.
- A count for each of the keywords either as separate variables or as a single array of counts.
- The name of the file read, i.e. test.txt or test2.txt .
- Make the following functions that take your structure as a parameter.
- A print function that is call by value.
- A data initialization function that is call by reference.
- You must have a .h and .cpp for your structure. I know they will be very short.
- Your .h must use #ifndef to ensure one-time compilation. This time use an ifndef.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started