Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVA!! Write a class called MusicApp that has only a main method. The program sh

ID: 3664506 • Letter: J

Question

JAVA!!

Write a class called MusicApp that has only a main method. The program should create several (three, at least) Song objects, and an Album object. The Songs should be added to the Album. Use the Album object to determine which song is the longest and shortest. Also find a sing by title. Finally, use Album's toString method to print the album's contents. Song and Album classes are included in the jar file you added to this project. The only code you need to write is the MusicApp main method.
Thanks!

Explanation / Answer

// Song and Album classes not available if you can provide the code of these two classes I can implement it better. But I will try to implement the main method based on the description of two classes given in the question.

import java.util.*;
import java.io.*;

public class MusicApp
{  
  
   public static void main(String s[])
   {
Song s1,s2,s3; // three song object references
Album alb;


// I assume song constructor will be having song title and duration (seconds) as parameters, so I will create sond objects using that constructor

s1=new Song("Beat It", 343 );
s2=new Song("Black n White", 298 );

s3=new Song("Criminal", 353 );

// Also album constructor will take album nas as argument

alb=new Album("Michael's Album");

// I assume Album class has a method to add songs to it

alb.addSong(s1);
alb.addSong(s2);
alb.addSong(s3);

// get longest song and print

System.out.println("Longest song of the album "+ alb.getLongestSong()+" and shortest song of the album "+ alb.getShortestSong()");

// Calling alb toString() mthod

System.out.println("Album details "+ alb);
  
   }
}