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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 17:30
Working on this program in python 3.7: a year in the modern gregorian calendar consists of 365 days. in reality, the earth takes longer to rotate around the sun. to account for the difference in time, every 4 years, a leap year takes place. a leap year is when a year has 366 days: an extra day, february 29th. the requirements for a given year to be a leap year are: 1) the year must be divisible by 42) if the year is a century year (1700, 1800, the year must be evenly divisible by 400some example leap years are 1600, 1712, and 2016.write a program that takes in a year and determines whether that year is a leap year.ex: if the input is 1712, the output is: 1712 is a leap year. ex: if the input is 1913, the output is: 1913 is not a leap year. your program must define and call the function isleapyear(useryear). the function should return true if the input year is a leap year and false otherwise.
Answers: 1
question
Computers and Technology, 22.06.2019 21:00
Write a method so that the main() code below can be replaced by the simpler code that calls method original main(): public class calcmiles { public static void main(string [] args) { double milesperhour; double minutestraveled; double hourstraveled; double milestraveled; milesprhour = scnr.nextdouble(); minutestraveled = scnr.nextdouble(); hourstraveled = minutestraveled / 60.0; milestraveled = hourstraveled * milesperhour; system.out.println("miles: " + milestraveled); } }
Answers: 2
question
Computers and Technology, 22.06.2019 22:00
What is the name of the option in most presentation applications with which you can modify slide elements? 1. the option enables you to modify a slide element in most presentation applications.
Answers: 3
question
Computers and Technology, 23.06.2019 04:20
4. a1. vince owns a television repair shop that is insured undera commercial package policy. the policy includes thebuilding and personal property coverage form and thecauses-of-loss broad form. the declarations page indicatesthat coverage applies to both the building and the namedinsured's business property. explain whether or not thefollowing losses would be covered under his policy.a. a fire occurs on the premises, and the building isbadly damaged.b. a burglar steals some money and securities from anunlocked safe.c. a business computer is damaged by vandals whobreak into the shop after business hours.d. a tornado touches down near the store. several tel-evision sets of customers in the shop for repair aredamaged in the storm.til
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
question
Mathematics, 16.07.2019 16:00
question
Advanced Placement (AP), 16.07.2019 16:00
Questions on the website: 13722363