20165237 2017-2018-2 "Java Program Design" Tenth week exam complement and programming questions

Source: Internet
Author: User

20165237 2017-2018-2 "Java Program Design" Tenth week exam complement and programming problem knowledge points

1. A linked list is a data structure consisting of several objects called nodes, each of which contains a reference to the next node.

2. The class method provided by the collections class for sorting and finding is as follows: public static sort (List

Data Structure-Sort:

Topic:
In data structures and algorithms, sorting is an important operation, and there are two ways to make a class available for ordering:

    • There are classes of source code, sort on a member variable, let the class implement comparable interface, call Collection.sort (List)
    • No class source code, or more than one sort, create a new class, implement comparator interface call Collection.sort (List, Compatator)

For the following student class, use comparator programming to complete the following functions:

    1. Create a new student list in the test class Studenttest, including two students and 5 students before and after the student number, giving the running results (before sorting, sorting)
    2. The 5 students were ordered by the number and the total scores, and submitted two comparator code
    3. Submit code to code cloud under class
Class Student {private string id;//notation private string name;//represents the name private int age;//expression age private Double Comp uter_score;//the results of the computer course private Double english_score;//Express English class results private double maths_score;//show math class results private Dou Ble total_score;//represents the total total of private double ave_score;        Represents the average score public Student (string ID, string name) {this.id = ID;    THIS.name = name;}        Public Student (string ID, string name, char sex, int.) {This (ID, name);        This.sex = sex;    This.age = age;} Public String GetId () {return ID;} Gets the number of the current object, public double Getcomputer_score () {return computer_score;} Gets the computer course score for the current object, public double Getmaths_score () {return maths_score;} Gets the current object's math course score, public double Getenglish_score () {return english_score;} Gets the English course score for the current object, public void SetId (String id) {this.id=id;} Sets the ID value of the current object, public void Setcomputer_score (double computer_score) {this.computer_score=computer_score;}//sets the Computer_score value of the current object, public void Setenglish_score (double english_score) {this.english_score=english_score; }//sets the English_score value of the current object, public void Setmaths_score (double maths_score) {This.maths_score=maths_score;} Sets the Maths_score value of the current object, public double Gettotalscore () {return computer_score+maths_score+english_score;}    Calculate the overall scores of Computer_score, Maths_score and English_score. Public double Getavescore () {return Gettotalscore ()/3;} Calculates the average score of Computer_score, Maths_score, and English_score in each class.    }class Undergraduate extends student{private String ClassID;        Public undergraduate (string ID, string name, char sex, int age,string ClassID) {super (id,name,sex,age);    This.classid=classid;    } public String GetClassID () {return classID;    } public void Setclassid (String classID) {this.classid=classid; }}
Complement:

Studentpx

git log:

Programming problem Code Hosting

(Results of program operation)
(1) Use the stack structure to output several items of an, where an=2an-1+2an-2,a1=3,a2=8

(2) write a program to store student English scores in a list in a tree set so that they are automatically sorted by program and output sorted results

(3) There are 10 USB drives, there are two important properties: price and capacity. Write an application that uses TreeMap

20165237 2017-2018-2 "Java Program Design" Tenth week exam complement and programming questions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.