ArrayList and arrays

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • miss time
    New Member
    • Jun 2007
    • 16

    #1

    ArrayList and arrays

    Hi,
    plese help to understand this question and see if my solution right

    Given that a PointXY object is even if the x-coordinate and y-coordinates are even numbers. Write a method in which it takes an array of PointXY and returns the number of even points in the array.
    i have orday define PointXY class so i write as follow:
    public int evenNo(int[] arr){
    int d=0;
    for(int i=0;i<arr.lengt h;i++)
    if(arr[i]%2==0){

    }
    return d;}

    2) Write a method that takes an array of Employees as a parameter and doubles the salary of each employee.
    i have Emplyees class and in this class i do get Salary ....
    please can you help to understand how to solve this question
  • BigDaddyLH
    Recognized Expert Top Contributor
    • Dec 2007
    • 1216

    #2
    Originally posted by miss time
    Write a method in which it takes an array of PointXY and returns the number of even points in the array.
    I would interpret this as:
    Code:
    int numberOfEvenPoints(PointXY[] points) {
    ...
    }
    Note that you are asked to define a method that takes an array of PointXY, not an array of int

    Comment

    Working...