联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Java编程Java编程

日期:2018-11-21 10:00

Homework 1 - Sorting Student Records

LP002 Data Structures

November 13, 2018

1 Introduction

You are asked to implement a tiny Java program to manage Student Records for our university. In

particular, your program should be able to read the score reports of students from a given file. More

specifically, your MSSR shall provide end users with efficient and effective sorting the given large

number of student records.

2 Specification

Your MSSR system shall provide users with sorting on a large number of student score records.

2.1 Read score records

The score report has the following format:

(a) The first line contains the number of records, says N (N ≥ 1).

(b) Each of the next N lines contains a comma separated list of student’s StudentID, Student

Name, Course Code and his/her obtained Score.

StudentID starting with ‘s’ occupies totally 11 characters.

Student Name is a varied string from 5 to 14 characters.

Course Code is a fixed 5-character string.

Score is an integer ranging from 0 to 100.

(c) You may assume there is no space before and after the comma delimiter and there is no trailing

space after each line of data.

(d) Note that you SHOULD NOT change the input data file format.

The following is an example of score report:

5

s1109853011,JackieChan,CS001,85

s0907451244,FrankPapadias,MA002,65

s0308893477,MirandaLambert,HM467,35

s4045128481,SophiaPam,CM604,75

s0812340023,PhilipsChiu,CS001,71

1

As shown in the above example, there are 5 students in this score report.

2.2 Store records

After reading the score reports successfully, your program should be able to store student scores. In

particular, your program should store the course information as follows:

Student:

Student ID

Student Name

Score

Code Code

Note:

You need to design a class to sore the student record.

You should specify enough space for each field defined in your class (data structure).

2.3 Sorting

You are required to display the report according to StudentID, student name, course code

and the score in either an ascending order or a descending order. For example as shown as follows,

the students are listed in ascending order lexicographically according to their StudentID.

output:

s0308893477,MirandaLambert,HM467,35

s0812340023,PhilipsChiu,CS001,71

s0907451244,FrankPapadias,MA002,65

s1109853011,JackieChan,CS001,85

s4045128481,SophiaPam,CM604,75

Note:

To specify which field to be sorted and the sorting ways (ascending or descending), you can let

user input it as a parameter.

2.4 Performance

Your system shall be efficient in both searching and sorting. In particular, the running time for a single

query of your system shall be less than 20 seconds with the number of records N is less than 100,000.

Every extra second leads to subtracting one point in your score (note that the time for reading

records will not be counted in the performance). Therefore, please try to call faster algorithms (e.g.

quick sort, merge sort and binary search trees, etc.) to implement your system.

2

2.5 Sample Input and Output

Input:

5

s1109853011,JackieChan,CS001,85

s0907451244,FrankPapadias,MA002,65

s0308893477,MirandaLambert,HM467,35

s4045128481,SophiaPam,CM604,75

s0812340023,PhilipsChiu,CS001,71

1 A

1 D

2 A

2 D

3 A

3 D

4 A

4 D

0

Output:

s0308893477,MirandaLambert,HM467,35

s0812340023,PhilipsChiu,CS001,71

s0907451244,FrankPapadias,MA002,65

s1109853011,JackieChan,CS001,85

s4045128481,SophiaPam,CM604,75

s4045128481,SophiaPam,CM604,75

s1109853011,JackieChan,CS001,85

s0907451244,FrankPapadias,MA002,65

s0812340023,PhilipsChiu,CS001,71

s0308893477,MirandaLambert,HM467,35

s0907451244,FrankPapadias,MA002,65

s1109853011,JackieChan,CS001,85

s0308893477,MirandaLambert,HM467,35

s0812340023,PhilipsChiu,CS001,71

s4045128481,SophiaPam,CM604,75

s4045128481,SophiaPam,CM604,75

s0812340023,PhilipsChiu,CS001,71

s0308893477,MirandaLambert,HM467,35

s1109853011,JackieChan,CS001,85

s0907451244,FrankPapadias,MA002,65

s4045128481,SophiaPam,CM604,75

s0812340023,PhilipsChiu,CS001,71

s1109853011,JackieChan,CS001,85

3

s0308893477,MirandaLambert,HM467,35

s0907451244,FrankPapadias,MA002,65

s0907451244,FrankPapadias,MA002,65

s0308893477,MirandaLambert,HM467,35

s0812340023,PhilipsChiu,CS001,71

s1109853011,JackieChan,CS001,85

s4045128481,SophiaPam,CM604,75

s0308893477,MirandaLambert,HM467,35

s0907451244,FrankPapadias,MA002,65

s0812340023,PhilipsChiu,CS001,71

s4045128481,SophiaPam,CM604,75

s1109853011,JackieChan,CS001,85

s1109853011,JackieChan,CS001,85

s4045128481,SophiaPam,CM604,75

s0812340023,PhilipsChiu,CS001,71

s0907451244,FrankPapadias,MA002,65

s0308893477,MirandaLambert,HM467,35

3 Submission

Your Submission

1. A soft copy of your source program including all the components.

2. readme file (readme.txt) which contains:

(a) file list

(b) file description

(c) methods of compilation

(d) method of execution

(e) known bugs of your system

A good example:

/ Assignment 1

Name : Alex Fung

Student ID: 1009853X?I011?YYYY

Section:LP002

email: alexfung@fakemail.com

Description:

This file contains the ThreeSum class, which counts

the number of tuples equal to 0.

4

public class ThreeSum

{

/ Description:

Brute force method to compute the the number of

tuples equal to 0 by checking condition:

a[i] + a[j] + a[k] == 0

Parameters:

a: the array

Return:

count: the number satisfying the condition

/

public static int count(int[] a)

{

int N = a.length; // The size of array

int count = 0; // the result

for (int i = 0; i < N; i++)

for (int j = i+1; j < N; j++)

for (int k = j+1; k < N; k++)

if (a[i] + a[j] + a[k] == 0)

count++;

return count;

}

/ A testing client reads an array from standard input

and prints the number of tuples equal to zero.

/

public static void main(String[] args)

{

int[] a = StdArrayIO.readInt1D();

StdOut.println(count(a));

}

}


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp