Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program that asks the user to enter the name of a file, and then asks the user to enter a character string. The
Write a program that asks the user to enter the name of a file, and then asks the user to enter a character string.
The program should count and display the number of times that the specified character string string appears in the file. Attached is a few files for your program to read and search for a particular character string to test the program.
Note: if aaaaaaaaaaa exists somewhere in the file and my search String is aa for this segment alone I have 10!
file1:
So you think you're a Romeo playing a part in a picture-show Take the long way home Take the long way home Cos you're the joke of the neighborhood Why should you care if you're feeling good Take the long way home Take the long way home But there are times that you feel you're part of the scenery all the greenery is comin' down, boy And then your wife seems to think you're part of the furniture oh, it's peculiar, she used to be so nice. When lonely days turn to lonely nights you take a trip to the city lights And take the long way home Take the long way home You never see what you want to see Forever playing to the gallery You take the long way home Take the long way home And when you're up on the stage, it's so unbelievable, unforgettable, how they adore you, But then your wife seems to think you're losing your sanity, oh, calamity, is there no way out? Does it feel that you life's become a catastrophe? Oh, it has to be for you to grow, boy. When you look through the years and see what you could have been oh, what might have been, if you'd had more time. So, when the day comes to settle down, Who's to blame if you're not around? You took the long way home You took the long way home...........
File2:
The class String includes methods for examining individual characters of the sequence, for comparing strings, for searching strings, for extracting substrings, and for creating a copy of a string with all characters translated to uppercase or to lowercase. Case mapping is based on the Unicode Standard version specified by the Character class.
file 3:
Doh Doh doh doh, doh doh doh, doh doh Doh doh doh, doh doh doh, doh doh Doh doh doh, doh doh doh, doh doh Doh doh doh, doh duh (Aaaaaaow!) This hit That ice cold Michelle Pfeiffer That white gold This one, for them hood girls Them good girls Straight masterpieces Stylin', while in Livin' it up in the city Got Chucks on with Saint Laurent Gotta kiss myself I'm so pretty I'm too hot (hot damn) Called a police and a fireman I'm too hot (hot damn) Make a dragon wanna retire, man I'm too hot (hot damn) Say my name you know who I am I'm too hot (hot damn) Am I bad 'bout that money Break it down Girls hit your hallelujah (whoo) Girls hit your hallelujah (whoo) Girls hit your hallelujah (whoo) 'Cause Uptown Funk gon' give it to you 'Cause Uptown Funk gon' give it to you 'Cause Uptown Funk gon' give it to you Saturday night and we in the spot Don't believe me, just watch (Come on) Doh Doh doh doh, doh doh doh, doh doh (Hah!) Don't believe me, just watch Doh Doh doh doh, doh doh doh, doh doh (Hah!) Don't believe me, just watch Don't believe me, just watch Don't believe me, just watch Don't believe me, just watch Hey, hey, hey, oh! Stop Wait a minute Fill my cup put some liquor in it Take a sip, sign a check Julio! Get the stretch! Ride to Harlem, Hollywood, Jackson, Mississippi If we show up, we gon' show out Smoother than a fresh jar o' Skippy I'm too hot (hot damn) Called a police and a fireman I'm too hot (hot damn) Make a dragon wanna retire, man I'm too hot (hot damn) (hot damn) Bitch, say my name you know who I am I'm too hot (hot damn) Am I bad 'bout that money Break it down Girls hit your hallelujah (whoo) Girls hit your hallelujah (whoo) Girls hit your hallelujah (whoo) 'Cause Uptown Funk gon' give it to you 'Cause Uptown Funk gon' give it to you 'Cause Uptown Funk gon' give it to you Saturday night and we in the spot Don't believe me, just watch (come on) Doh Doh doh doh, doh doh doh, doh doh (Hah!) Don't believe me, just watch Doh Doh doh doh, doh doh doh, doh doh (Hah!) Don't believe me, just watch Don't believe me, just watch Don't believe me, just watch Don't believe me, just watch Hey, hey, hey, oh! Before we leave Let me tell y'all a lil' something Uptown Funk you up, Uptown Funk you up Uptown Funk you up, Uptown Funk you up, uh I said Uptown Funk you up, Uptown Funk you up Uptown Funk you up, Uptown Funk you up Come on, dance Jump on it If you sexy then flaunt it If you freaky then own it Don't brag about it, come show me Come on, dance Jump on it If you sexy then flaunt it Well it's Saturday night and we in the spot Don't believe me, just watch (come on) Doh Doh doh doh, doh doh doh, doh doh (Hah!) Don't believe me, just watch Doh Doh doh doh, doh doh doh, doh doh (Hah!) Don't believe me, just watch Don't believe me, just watch Don't believe me, just watch Don't believe me, just watch Hey, hey, hey, oh! Uptown Funk you up, Uptown Funk you up (say whaa?!) Uptown Funk you up, Uptown Funk you up Uptown Funk you up, Uptown Funk you up (say whaa?!) Uptown Funk you up, Uptown Funk you up Uptown Funk you up, Uptown Funk you up (say whaa?!) Uptown Funk you up, Uptown Funk you up Uptown Funk you up, Uptown Funk you up (say whaa?!) Uptown Funk you up Aaaaaaow!
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