Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program named SongLyrics that reads from the file a2q4.txt and displays some information: a) The number of lines in the song b) The

Write a program named SongLyrics that reads from the file a2q4.txt and displays some information: a) The number of lines in the song b) The number of words in the song - A word does not contain a numeric character e.g. 3 and 4ever are not considered words c) The sum of the values of numeric tokens - A numeric token is a token that contains all digits e.g. 3 and 6000 are numeric tokens because they can be added together, 7-11 and 4ever contain numbers but are not completely numeric Sample output: Number of song lines:36 Number of words: 186 Sum of numbers: 1009 Notes: - Assume that all lyrics have no sentence punctuation (like the sample data) - Sample data is provided but your code must work with any data - Include at least 1 method in your solution (apart from main)

1000 years or more ago
When I was newly sewn
There lived 4 wizards of renown
Whose names are still well known
Bold Gryffindor from wild moor
Fair Ravenclaw from glen
Sweet Hufflepuff from valley broad
Shrewd Slytherin from fen
They shared a wish a hope a dream
They hatched a daring plan
To educate young sorcerers
Thus Hogwarts School began
Now each of these 4 founders
Formed their own house for each
Did value different virtues
In the ones they had to teach
By Gryffindor the bravest were
Prized far beyond the rest
For Ravenclaw the cleverest
Would always be the best
F0r Hufflepuff hard workers were
Most worthy of admission
And power-hungry Slytherin
Loved those of great ambition
Whi1e still alive they did divide
Their favorites from the throng
Yet how to pick the worthy 1
When they were dead and gone
'Twas Gryffindor who found the way
He whipped me off his head
The founders put some brains in me
So I could choose instead
Now slip me snug about your ears
I've never yet been wrong
I'll have a look inside your mind
And tell where you belong

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

Students also viewed these Databases questions