So, when I tried to compile this code it had one error which I thought I found (a missing bracket) but now it shows I have 65 errors. Can you take a look and let me know if I have put things in the correct order or if my code is just incorrect? Here's the code: import java.util.*; class RecordSort extends Record { public static void main(String[]args) { Recording[]recordings = new Recording[5]; int x; String songTitle, artist, order, message = ""; int playTime; for(x=0;x0) { temp = array[b]; array[b] = array[b+1]; array[b+1] = temp; } } } public static void sortBySongTitle(Recording[] array) { int a, b; Recording temp; String stringB, stringBPlus; int highSubscript = array.length -1; for(a=0; a< highsubscript; ++a) for(b=0; b< highSubscript; ++b) { stringB = array[b].getSongTitle(); stringBPlus = array[b+1].getSongTitle(); if(stringB.compareTo(stringBPlus)>0) { temp = array[b]; int highSubscript = array.length -1; for(a=0; a < highSubscript; ++a) for(b=0; b < highSubscript; ++b) { stringB = array[b].getSongTitle(); stringBPlus = array[b+1].getSongTitle(); if(stringB.compareTo(stringBPlus)>0) { temp = array[b]; array[b] = array[b+1]; array[b+1] = temp; } } } public static void sortByTime(Recording[] array) { int a, b; Recording temp; int highSubscript = array.length -1; for(a=0; a < highsubscript; ++a) for(b=0; b < highSubscript; ++b) { if(array[b].getPlayTime().array[b+1].getPlayTime()) { temp = array[b]; array[b]= array[b+1]; array[b+1] = temp; } } } } ______________________ public class Record { private String songTitle; private String artist; private int playTime; public void setSongTitle(String title) { songTitle = title; } public void setArtist(String name) { artist = name; } public void setPlayTime(int time) { playTime = time; } public String getSongTitle() { return songTitle; } public String getArtist() { return artist; } public int getPlayTime() { return playTime; } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

So, when I tried to compile this code it had one error which I thought I found (a missing bracket) but now it shows I have 65 errors.

Can you take a look and let me know if I have put things in the correct order or if my code is just incorrect?

Here's the code:

import java.util.*;

class RecordSort extends Record
{

public static void main(String[]args)
{
Recording[]recordings = new Recording[5];

int x;
String songTitle, artist, order, message = "";

int playTime;
for(x=0;x<recordings.length;++x)

{
Scanner input = new Scanner(System.in);

System.out.print("Enter the song title: " + (x+1));

SongTitleEntry=input.nextLine();
}

System.out.print("Enter artist of the song: " +(x+1));

ArtistEntry=input.nextLine();


System.out.print("Enter the song playtime in seconds: " +(x+1));

PlayTimeEntry=input.nextInt();

time = Integer.parseInt(timeString);

Recording temp = new Recording();

temp.setArtist(name);
temp.setSongTitle(title);
temp.setPlayTime(time);

recordings[x] = temp;
}
Scanner input = new Scanner(System.in);
System.out.print("Which field should recordings be sorted by- \n" +
"(S)ong Title, (A)rtist, or (T)ime?");

if(order.charAt(0) == 'S')

sortBySongTitle(recordings);

else
if(order.charAt(0) == 'A')

sortByArtist(recordings);

else

sortByTime(recordings);

for(x = 0; x<recording.length; ++x)

System.out.println(message=message + "\nartist: " +recordings[x].getArtist() +
" song: " +recordings[x].getSongTitle() + " time: " + recordings[x].getPlayTime());
}

public static void sortByArtist(Recording[] array)
{

int a, b;
Recording temp;
String stringB, stringBPlus;
int highSubscript = array.length -1;

for(a=0; a < highSubscript; ++a)

for(b=0; b < highSubscript; ++b)

{
stringB = array[b].getArtist();
stringBPlus = array[b+1].getArtist();

if(stringB.compareTo(stringBPlus)>0)

{
temp = array[b];
array[b] = array[b+1];
array[b+1] = temp;
}
}
}

public static void sortBySongTitle(Recording[] array)
{

int a, b;
Recording temp;
String stringB, stringBPlus;
int highSubscript = array.length -1;

for(a=0; a< highsubscript; ++a)

for(b=0; b< highSubscript; ++b)
{

stringB = array[b].getSongTitle();
stringBPlus = array[b+1].getSongTitle();

if(stringB.compareTo(stringBPlus)>0)

{
temp = array[b];

int highSubscript = array.length -1;

for(a=0; a < highSubscript; ++a)

for(b=0; b < highSubscript; ++b)

{
stringB = array[b].getSongTitle();
stringBPlus = array[b+1].getSongTitle();

if(stringB.compareTo(stringBPlus)>0)

{
temp = array[b];
array[b] = array[b+1];
array[b+1] = temp;
}
}
}

public static void sortByTime(Recording[] array)
{

int a, b;
Recording temp;
int highSubscript = array.length -1;

for(a=0; a < highsubscript; ++a)

for(b=0; b < highSubscript; ++b)

{

if(array[b].getPlayTime().array[b+1].getPlayTime())

{
temp = array[b];
array[b]= array[b+1];
array[b+1] = temp;

}
}
}
}

______________________

public class Record
{
private String songTitle;
private String artist;
private int playTime;

public void setSongTitle(String title)
{
songTitle = title;
}

public void setArtist(String name)
{
artist = name;
}

public void setPlayTime(int time)
{
playTime = time;
}

public String getSongTitle()
{
return songTitle;
}

public String getArtist()
{
return artist;
}

public int getPlayTime()
{
return playTime;
}
}

 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 5 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education