Question: (c++) Prompt user to enter a file name (can assme it is always going to be example.txt). For each word in that file, spelling will
(c++) Prompt user to enter a file name (can assme it is always going to be example.txt). For each word in that file, spelling will be checked, excluding any punctuation marks at the end and also converting a first letter that is uppercase to a lowercase except for the word "I". The input file, example.txt will be preserved and printed to the console with astericks* surrounding the mispelled words. The valid spelling of a word, other than "I," will be either spelling beginning with a lowercase letter or the spelling beginning with an uppercase letter. For example: "Rice" and "rice" are valid but "rICE" is not.
Use unordered_set under
isWhiteSpece: accepts a char and returns a bool, true if character is white space and otherwise false
dePuntuate: return void, accepts a string as an input and removes its terminating punctuation mark and makes the first letter lowercase
isValidWord: accepts the collection of dictionary spellings and a depunctuated word to checl, return true if the word has a valid spelling and otherwise false
finalPunctuation: returns a bool, true if the final character is a punctuation mark and otherwise false
First, get a vector to store all the display as a collection of words and strings of white space.
Read as much white space as possible from the file that is being spell-checked (example.txt), one char at a time, using int get() const; and int peek() const; and isWhiteSpece abd store all the white space as a string to be printed in the vector stooring the final console display.
Now, there is a word and the word should be read from the stream. Then check if the word has valid spelling by using dePunctuate and isValidWord. If spelling valid, store it including punctuation marks to print in vector. OTHERWISE, check if the word ends in punctuation using finalPunctuation.
pseudo code:
if (('Aa'
c+= ('a' - 'A'); } //if c is a char, convert c to lowercase if it is uppercase
REPEAT UNTIL STREAN US EXHAUSED then print all strings from the vector

The desired output given example.txt with dictionary.txt is provided below Enter file to spell check: example.txt That Time I Tried Skateboarding *oNce* upon a time, I was at a *sleepover* at *rfriend's* *plce. we were evil *kds i and we made some prank callsandafterwards,my friend "uggestedI learn to skatebo ard. I was a little reluctant, but at 2 *a 1 didn't have the wisdom to "jsut" say no Things began all right: I could balance quite "welll when standing on the board as it rested on the grass And I could even balance a little on the board when it was rougly stationary on t he sidewalk. "Naturily, the next thing to try was a little skateboarding from the sidewalk onto the road Gracefully, I pushed myself and the skateboard forward, toawrds the road. Unbekno nst to me, however, was the fact that the curb was very, very steep: there was no gentle g radient but an abrupt drop of about a foot And so, I lost my balance and fe11 offf the b ard. The board glided smothleyinto the street and I, instinctively, flailed my arms bac kwards as I fel1 and managed to land perfectly on my left middle finger. ouch! I told myfrined" that my finger really hurt and he said, that it would be better in the morning. I agreed We went back in the house and eventually slept. It wasn't until the next day, after my parents picked me up, when my finger was "aabsolutelythrobbing that I suggested the p ssibility that my finger was broken A few hours later, after some x-rays indeed ny middle finger was broken. So I ha d to wear this claw-1ike cast on my hand fr about a month. And that was the first and las t time I tried to skatboard
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
