Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java please, The java program should read lyrics from a file found in the same directory as the program. It The program should read

In java please,

The java program should read lyrics from a file found in the same directory as the program. It The program should read the lyrics for each line and treat each word as a token. Embedded in each line will be the line number for that line. The number may occur anywhere within the line and each line is guaranteed to have one number in it. The program should read each line, remove the integer within the line and put the integer into one array. For all the words that occur in the line, put them into a separate String array. After reading all the lines, use the Selection Sort algorithm that sorts the two arrays in parallel. After sorting all the lines, display the lyrics in order corresponding to the number embedded within each line. The output should have the first character of the first word at the beginning of the line. The output should contain one space between each word. A word is a continuation of characters until it reaches a space.

Vivir mi 6 vida, la la la la Voy a reir, voy a 3 gozar A veces llega 9 la lluvia Voy a reir, 1 voy a bailar 10 Para limpiar las heridas Vivir mi vida, 2 la la la la Voy a reir, 7 voy a gozar Vivir mi vida, 8 la la la la 4 Vivir mi vida, la la la la Voy 5 a reir (Ay eso!), voy a bailar

So the program should print to the screen the following:

Voy a reir, voy a bailar Vivir mi vida, la la la la Voy a reir, voy a gozar Vivir mi vida, la la la la Voy a reir (Ay eso!), voy a bailar Vivir mi vida, la la la la Voy a reir, voy a gozar Vivir mi vida, la la la la A veces llega la lluvia Para limpiar las heridas
  1. If the file does not exist, then the program should instead display, File not found and exit.
  2. If the lyrics.txt contains more than 200 lines, it should display, The song is too long and exit.
  3. If the lyrics file is empty, the program should display, Empty file and exit.

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

More Books

Students also viewed these Databases questions

Question

c. What were you expected to do when you grew up?

Answered: 1 week ago

Question

4. Describe how cultural values influence communication.

Answered: 1 week ago

Question

3. Identify and describe nine cultural value orientations.

Answered: 1 week ago