Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.io.*; /** This program creates a list of songs for a CD by reading from a file. */ public class Main {


image

import java.io.*;

/**
  This program creates a list of songs for a CD
  by reading from a file.
*/

public class Main
{
  public static void main(String[] args)throws IOException
  {
     FileReader file = new FileReader("Classics.txt");
     BufferedReader input = new BufferedReader(file);
     String title;
     String artist;

     // ADD LINES HERE
     // Declare an array of Song objects, called cd,
     // with a size of 6

     for (int i = 0; i < cd.length; i++)
     {
        title = input.readLine();
        artist = input.readLine();

        // ADD LINES HERE
        // Fill the array by creating a new song with
        // the title and artist and storing it in the
        // appropriate position in the array

     }

     System.out.println("Contents of Classics:");
     for (int i = 0; i < cd.length; i++)
     {
        // ADD LINES HERE
        // Print the contents of the array to the console
       
     }
  }
}


click on Fork to make a copy of the lab. Song.java is complete and will not be edited. Classics.txt is the data file that will be used by Main.java, the file you will be editing. 3. In Main.java, there are comments indicating where the missing code is to be placed. Declare an array of Songs, called cd, with a size of 6. 4. Fill the array by creating a new song with the title and artist and storing it in the appropriate position in the array. 5. Print the contents of the array to the console. 6. Compile, debug, and run. Your output should be as follows: Contents of Classics: Ode to Joy by Bach The Sleeping Beauty by Tchaikovsky Lullaby by Brahms Canon by Bach Symphony No. 5 by Beethoven The Blue Danube Waltz by Strauss

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Here is the modified code with the missing code added java import javaio This program creates a list ... 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

Java How To Program Late Objects Version

Authors: Paul Deitel, Deitel & Associates

8th Edition

0136123716, 9780136123712

More Books

Students also viewed these Programming questions