forked from Denisolt/CSCI-160
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompactDisc.java
More file actions
34 lines (31 loc) · 876 Bytes
/
CompactDisc.java
File metadata and controls
34 lines (31 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**This program creates a list of songs for a CD by reading from a file*/
import java.io.*;
/*
* 11/05/2015
*/
public class CompactDisc
{
public static void main(String [] args) throws IOException
{
FileReader file = new FileReader("Classics.txt");
BufferedReader input = new BufferedReader(file);
String title;
String artist;
String[] cd = new String [6];
//Declare an array of songs, called cd, of size 6
for (int i = 0; i < cd.length; i++)
{
title = input.readLine();
artist = input.readLine();
cd[i] = title + "\n" + artist;
// 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++)
{
System.out.println(cd[i]);
}
}
}