Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE HELP ON JAVA: Using the input file called StudentInputFile.txt, input these students into a linked list sorted according to their age. In each case

PLEASE HELP ON JAVA:

Using the input file called StudentInputFile.txt, input these students into a linked list sorted according to their age. In each case I made the student's last name their age as a string so when the input file says "John" "Twenty" 20 this means the student's first name is John, last name is Twenty, and age is 20. This is so that when you output the list you can easily tell if it is sorted by looking at the last names.

I have given you a class called Student. You will have to add a compareTo method so this class can implement comparable. Do NOT add a getAge() method to the class. In main I want you to be able to compare two Student objects.

Do not use an array or any other data structure other than the list. Do not add them to the list and then sort the list. I want you to add each node to the list in the "correct" place in order to keep the list sorted as you are building it. Then output the contents of the list.

StudentInputFile.txt

Marty Twenty 20

Elizabeth Fifty 50

Christy Nineteen 19

Graham TwentyFive 25

Doris FiftyOne 51

Eleanor ThirtyFive 35

Mark Nineteen 19

Margaret Forty 40

Jessica ThirtyOne 31

Student Class:

class Student{

private String name;

private int age;

public Student(String n, int a)

{ name = n;

age=a;

}

public String toString()

{ return name;

}

}

RUBRIC:

compareTo method in Student

correctly input from file, use of try/catch

method to add to list in sorted order. If no method, just statements in main.

printList method

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions