Question: ********* JAVA HELP ************* i need help to modify this code becuase when I ran the program I got two errors ( Students.java:10: error: class,

********* JAVA HELP *************

i need help to modify this code becuase when I ran the program I got two errors

( Students.java:10: error: class, interface, or enum expected Student.java ^ Students.java:82: error: class, interface, or enum expected StudentTest.java ^ 2 errors)

Also, I'd like to start my code with

public class Student {

public static void main(String[] args) {

Just make it look simple to me, so in case later if i need to modefiy I can edit it by my self & understand better i'm just a beginner

here is the code

________________________________________________

Student.java

public class Student

{

//attributes

private int id;

private String name;

//default constructor

public Student()

{

id=0;

name="";

}

//parameterized constructor

public Student(int id, String name) {

super();

this.id = id;

this.name = name;

}

//setters and gettes

public int getId() {

return id;

}

public void setId(int id) {

this.id = id;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

@Override

public String toString() {

return "Student [id=" + id + ", name=" + name + "]";

}

}

StudentTest.java

public class StudentTest

{

public static void main(String args[])

{

Student student[] = new Student[5];//array of student objects

//creating and adding objects to array

student[0]=new Student(3,"Mohammad");

student[1]=new Student(5,"Lynda");

student[2]=new Student(4,"Ashun");

student[3]=new Student(2,"Lydia");

student[4]=new Student(1,"Marbella");

//printing array in sorted order

System.out.println("Students in unsorted order:");

for(int i=0;i

System.out.println(student[i].toString());

//using bubble sort to sort the student objects in sorted order

for(int i=0;i

{

for(int j=0;j

{

if(student[j].getId()>student[j+1].getId())

{

Student temp=student[j];

student[j]=student[j+1];

student[j+1]=temp;

}

}

}

//printing array in sorted order

System.out.println("Students in sorted order:");

for(int i=0;i

System.out.println(student[i].toString());

}

public void doStuff(int n)

{

if (n

try {

throw new Exception("Negative number.");

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

__________________

the output should be like

********* JAVA HELP ************* i need help to modify this code becuase

StudentTest [Java Application] C:\F Students in unsorted order: Student [id-3, name-jhon] Student [id-5, name-Abraham] Student [id-4, name-Denny] Student [id-2, name-Lilly] Student [id-1, name Adam] Students in sorted order: Student [id-1, name Adam] Student [id-2, name-Lilly] Student [id-3, name-jhon] Student [id-4, name-Denny] Student [id-5, name-Abraham]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!