subject

I'm having issues of running this code, can anyone help? Here's the instructions: Write an application that instantiates five Recording objects and prompts the user for values for the data fields. Then prompt the user to enter which field the Recordings should be sorted by—song title, artist, or playing time. Perform the requested sort procedure, and display the Recording objects. Save the file as RecordingSort. java.

Here's the code that I'm working on:

import java. util. Scanner;

public class RecordingSort {

public static void main(String[] args) {

// initializes array for Recording objects
Recording[] list = new NRecording[5];

Scanner input = new Scanner(System. in);

int i = 0;
// prompts user for song title, artist, and playing time.
// takes information and stores it within object
for (i = 0; i 0 && sortMethod 0) {

// reorders the songs if necessary

Recording temp = list[b];
list[b] = list[c];
list[c] = temp;
}
}
// sorts by artist

else if (sortMethod == 2) {

// compares name of one artist with the name of the artist immediately after it

if (list[b].getArtist().compareTo(list [c].getArtist()) > 0) {

// reorders the songs if necessary

Recording temp = list[b];
list[b] = list[c];
list[c] = temp;
}
}

// sort by playing time

else if (sortMethod == 3) {

// compares one song's playing time with playing time of the song immediately after it

if (list[b].getPlayingTime() > list[c].getPlayingTime()) {

// reorders the songs if necessary

Recording temp = list[b];
list[b] = list[c];
list[c] = temp;
}
}
}
}
}
else {
System. out. println("Invalid choice. Please choose 1, 2, or 3.");
}
} while (sortMethod 3); // continues loop if user chooses invalid number

// adds line space

System. out. println();

// displays songs in whatever order was chosen

for (i = 0; i < list. length; i++) {
System. out. println("Song: Title: " + list[i].getTitle() + ". Artist: " + list[i].getArtist() + ". Playing time: "
+ list[i].getPlayingTime() + " seconds.");
}

// closes scanner
input. close();

}
}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 23:00, SuperWoman9172
What is one of the main problems that can occur when implementing a large number of new systems within an organization?
Answers: 1
image
Computers and Technology, 22.06.2019 07:00, ayoismeisalex
Our primary purpouse as electricians is to do wich of the following core concepts? a: install electrical components in a way they can be upgraded b: install electrical equiptment in a way that reduces heat c: install electrical systems in a safe manner d: only b and c
Answers: 1
image
Computers and Technology, 22.06.2019 13:00, mariahrpoulin9630
Which part of the cpu accepts data?
Answers: 1
image
Computers and Technology, 22.06.2019 21:30, aesthetickait
How do you take a green screen out of the video while editing?
Answers: 2
You know the right answer?
I'm having issues of running this code, can anyone help? Here's the instructions: Write an applicat...

Questions in other subjects:

Konu
Mathematics, 03.08.2019 07:50
Konu
Mathematics, 03.08.2019 07:50