keep in mind the essentials of program design; each basic operation you perform
ID: 3632443 • Letter: K
Question
keep in mind the essentials of program design; each basic operation you perform should be in one (or more, if necessary) method (s).
For this assignment, you are to write a Java program to perform some manipulations on a list of students’ marks. Given the ever-increasing class sizes at universities, your program should use a linked list to store the mark for each student.
Each node in the linked list should contain two pieces of data-the student’s number (an integer) and that student’s mark (a double). In the linked list, student marks should be stored in order of descending mark values; thus, the first student in the linked list should be the one with the highest mark, the second in the list should have the second highest mark, and so on. This order should be maintained for each student added to the list (when you add a new node to the linked list, insert it at the correct position to maintain sorted order).
Input data to your program will consist of a file containing student number and mark pairs, one per line. For example, the file might contain:
11111 63.5
22222 59.9
33333 82.4
Every time you read in a line from the file, dynamically create a new node containing that student’s number and mark, and insert it in the correct position in the linked list. For example:
After reading the first line of data:
Top-> 11111 / 63.5
Second line:
Top->11111 / 63.5 - -> 22222 / 59.9
Third line:
Top-> 33333 / 82.4 - -> 11111 / 63.5 -> 22222 / 59.9
After reading in all of the data and storing it in your list, you should perform two operations on the list. First, you should print out the contents of the linked list, from start to finish, nearly in a table. For example:
Student Number: Mark:
=============== =====
33333 82.4
11111 63.5
22222 59.9
Secondly, you should print out the median mark in the list. However, there are two rules you must follow. First, the method you use to calculate the median mark must be recursive. The function/method which calculates the median cannot use any loops, or call any functions which use loops. This function should return the node in the list which contains the median mark. Secondly, in order to find the median, you need to know how many items in total are in the list. Your recursive function must calculate that number (also recursively); you may not keep track of this count elsewhere your program. Your recursive solution should only examine each node only once, and the depth of the recursion should be equal to the number of nodes in the list. In order to make this (slightly) easier, the normal mathematical calculation for determining median is eased somewhat-if you have an even number of nodes in your list, either of the two marks in the middle may be considered the median (for example, if your list contains the four marks {90, 80, 70, 60 }, your function could return either 80 or 70 for the median). From the example above, your program should print out something like:
The median mark is 63.5, by student number 11111.
You do not require to have any interface, but are encouraged to do so.
try this data set and save it as "test.txt"
Data set :
11111 63.5
22222 59.9
33333 82.4
44444 70.1
55555 72.3
66666 89.5
77777 68.7
88888 53.2
99999 66.8
Explanation / Answer
Hey friend i have solved this question in my notebook but due to some upload error i can't upload the images . If you want to have the answer, please give me life saver and along with your email id !
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.