Computers and Technology
Computers and Technology, 30.09.2020 05:01, narnia85

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();

}
}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 18:30, lizz1228
Kto rozmawia z clamentain przez krótkofalówke w the walking dead w 4 epizodzie
Answers: 1
image
Computers and Technology, 23.06.2019 07:30, barkonatree
What is the penalty for violating section 1201 of title 17 chapter 21 of the us code
Answers: 1
image
Computers and Technology, 24.06.2019 14:00, ameliaxbowen7
Which computer tools allow you to communicate with coworkers, family, and friends
Answers: 1
image
Computers and Technology, 24.06.2019 14:30, heathersloan274
Which computer network component connects two different networks together and allows them to communicate? a is a node (or a device) that connects two different networks together and allows them to communicate.
Answers: 1
Do you know the correct answer?
I'm having issues of running this code, can anyone help? Here's the instructions: Write an applicat...

Questions in other subjects: