Results 1 to 3 of 3

Thread: java help

  1. #1
    Rabea is offline Member
    Join Date
    May 2012
    Posts
    2
    Rep Power
    0

    Default java help

    please can somone help me with any question here, i have to deliver these questions, but i don't understand them , and i need the grades , midterms 11/30, which sucks ..

    so please any help even help me understand how to solve




    This TMA covers units 1-6, 9-10. This TMA consists of 3 questions, and the total mark is out of 60.
    Important Enter your solutions to this TMA into a Solution Document. This document must be readable in Word. If you are in any doubt, try reading your document using WordViewer before submitting it to the e-TMAs system.
    To avoid sending over-large files through the e-TMA system (something that can cause problems to those marking your assignment) please:
    • prepare your Solution Document using Word if you have it;
    • avoid sending an RTF document;
    • do not copy screen shots, use copy and paste

    Question One: [10 marks]

    Use the code below to answer the following questions:

    public class Student {
    protected final static int NUM_OF_TESTS = 3;
    protected String name;
    protected int[] test;
    protected String courseGrade;

    public Student( )
    { System.out.println("No Name"); }

    public Student(String studentName) {
    name = studentName;
    test = new int[NUM_OF_TESTS];
    courseGrade = "****";
    }
    public void setScore(int s1, int s2, int s3)
    { test[0] = s1; test[1] = s2; test[2] = s3; }

    public String getCourseGrade( )
    { return this.courseGrade; }

    public String getName( )
    { return this.name; }

    public int getTestScore(int testNumber)
    { return this.test[testNumber-1]; }

    public void setName(String newName)
    {this.name = newName; }
    }
    /**************************************************
    public class GraduateStudent extends Student {
    public GraduateStudent(String na)
    { super(na);}

    public void computeCourseGrade() {
    int total = 0;
    for (int i = 0; i < NUM_OF_TESTS; i++)
    total += test[i];
    if (total >= 80)
    courseGrade = "Pass";
    else courseGrade = "No Pass";
    }

    } //class

    1. Give an example of each of the following from the above code: [3 marks]
    a. Accessor method.
    b. Mutator method.
    c. A Java message that call constructor of upper class.
    d. A pseudo variable that refers to receiver.
    e. An assignment statement using copy semantic.
    f. Reference type variable.

    2. What does overloading mean? Give an example from the above code. [2 marks]

    3. Write Java statements to do the following:
    a. Declare and create an object called student1 of class GraduateStudent whose name is "Ahmad". [2 marks]
    b. Call a method to give the following test scores for Ahmad: 90, 88, 83 [1 mark]
    c. Call a method to compute course grade for Ahmad. [1 mark]
    d. Print out course grade for Ahmad. [1 mark]
















    Question Two: [25 marks]

    1. Write an interface Sporty that has two methods: exercise(int), and getReady(), where those methods return no values. [3 marks]

    2. Write header of class ActiveHoverFrog that inherits HoverFrog class and implements Sporty interface. Write the following methods in class ActiveHoverFrog:
    [2 marks]
    a. A zero argument constructor of ActiveHoverFrog, where it calls parent constructor to initialise inherited attributes. [2 marks]

    b. The method getReady() which works as follows: [6 marks]
    On receipt of this method, an instance should turned into Red. After that, the following is repeated until the instance is at stone 6: it goes directly to height 3 and moves one stone towards stone 6 before returning directly to ground level again.

    c. Implement exercise(int n) method as follows: [5 marks]
    On receipt of this method, an instance should executes the number of exercises indicated by the message’s argument. Each exercise consists of hovering up by 1, moving to the left, hovering down by 1, and moving to the right. After finishing whole exercises a dialog box with a message "It's Done" is displayed.

    3. Draw the class diagram of Frog, HoverFrog, ActiveHoverFrog and Sporty. [4 marks]

    4. In the following Java statements, there are 3 invalid statements. List the invalid statements and explain why they are invalid. [3 marks]
    Sporty s1 = new Sporty(); //1
    HoverFrog f1 = new HoverFrog(); //2
    ActiveHoverFrog bouncy = new ActiveHoverFrog(); //3
    bouncy.right(); //4
    bouncy.exercise(3); //5
    ActiveHoverFrog kermit; //6
    f1.getReady(); //7
    kermit = f1; //8











    Question Three: [25 marks]

    The following table represents a part of a student grades, showing various student names with their grades.

    Name Grade
    “Ali” 82
    “Ahmad” 70
    “Rana” 95
    “Bader” 88

    This table is to be implemented and managed by an instance of a class called StudentGrade. The student names must be maintained in ascending order.

    1. Write the code of the class StudentGrade such that it includes a single attribute: index that will reference a collection suitable for holding the data in table1. In addition, the class will include the following methods:
    a. A zero argument constructor for StudentGrade that initializes index to an instance of a suitable empty collection class.

    b. A public instance method called filling() for the StudentGrade class that takes no arguments and returns no value. This method should simply fill the index with the data in table 1.

    c. A public instance method for the StudentGrade class called: findNamesBetweenGrades(int a, int b). This method returns an entire collection of names that are found in the grades between two arguments a and b. Assume always that a is less or equal to b.

    d. A public instance method for the StudentGrade class called brint(). This method prints the index entries. Use for-each statement.

    e. A public instance method for the StudentGrade class called maximum(). This method returns the name of the student who has the maximum grade of the index entries.

    2. Write Java statements to do the followings:

    a. Declare and create an object called m255 of StudentGrade class
    b. Use m255 object to call filling() method
    c. Print out the name of the student who has the maximum grade in M255 object via calling the suitable method from StudentGrade class.

  2. #2
    LuckyTampon is offline Member
    Join Date
    May 2012
    Location
    United Kingdom
    Posts
    1
    Rep Power
    0

    Default Re: java help

    You need to try set out your threads better by using code tags and stop using too many tabs, then somebody will probably help you. I'm not the smartest person but that I do know.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: java help

    Come on now. We're not here to do your work for you, and you need to show *some* evidence of effort, not dump your homework or other work in the forum without showing evidence of effort. Locking this thread.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •