need some help. just wanted to know if my code is right can some one read over these instuctions and tell me if my code is right like the directions

If the size of the array is less than its capacity, then the value is added to the array and the size is increased by 1. In this case return true. If the value cannot be added, return false.
public int getRank(double value)
This returns the percentile rank of the value. The value is in the pth percentile rank if it is greater than p% of the values in the array, but not greater than p+1% of the values in the array. The return value should always be between 0 and 100. If the array is empty, return 0.

public double getPercentile(int p)
This returns the value of the pth percentile. A value stored in the array is the pth percentile if it is greater than or equal to at least p% of the values and less than or equal to at least (100-p)% of the values. Return the first value in the array that satisfies these conditions. if p is not between 0 and 100 (inclusive), return 0. If the array is empty, return 0. Otherwise, there should be at least one value in the array satisfying the condition.
Hint: Write a private helper method that determines whether a given value is the pth percentile. Call this for each element in the array until you find one that works.

``````//part 2
if(size<capacity)
value+=1;
size ++;
return false;

}
public static int getRank(double [] value){
int rank = 0;
for(int i=0;i<value.length;i++)
if(i > rank%value.length &  i != rank+1)
return rank;
return 0;

}
public double getPercentile(int [] p){
int value=0;
for(int i=0;i<p.length;i++)
if(i>=value%p.length || i<=p.length%i&&i<=100-p.length%p.length)
return value;

return 0;

}``````
3
Contributors
4
Replies
11
Views
7 Years
Discussion Span
Last Post by stevelg

is it suppose to be like this

``````public boolean add(double value){
if(size<capacity)
value= value[]+1;
size ++;
return false;``````

The methods shown will not do anything like what you are asked.

The method getRank sets the value of Rank to 0 at line 10 but never alters or resets it to anything else. So the return at line 13 will be 0 irrespective of what you expect line 12 to achieve!

Similarly the returned 'value' in the method get Percentile is set to zero and never altered.

You need to give some thought as to what these routines are supposed to do and then consider what form your data needs to be in first!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.