Question
Devise an algorithm and implement it in a program to solve the following problem, similar to one often faced by an MP3 player. For our
Devise an algorithm and implement it in a program to solve the following problem, similar to one often faced by an MP3 player. For our purposes, a song consists of the following data fields: title (a nonempty ASCII string), composer (a (possibly empty) ASCII string), running time (a positive integer). Input consists of n songs and an integer with 1 〈 k 〈 n. Your program must find the songs with longest running times, and output these songs in descending order of length of song. If songs have the same running time, then we use lexicographic order on the title, and then on the composer, to get a total ordering. The lexicographic order comes from the usual order on ASCII characters Instruction: the first line gives the integer k, and the second line a separator character that is not contained in any of the song or composer strings. The sub sequence lines give the song data, with fields separated by the separator character
Step by Step Solution
3.48 Rating (158 Votes )
There are 3 Steps involved in it
Step: 1
Here my JAVA Code packagemp2song importjavautilScanner class Song String title String composer int r...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