I have no idea of this programe. // FloorCeil.java public class FloorCeil { // R
ID: 3539764 • Letter: I
Question
I have no idea of this programe.
// FloorCeil.java
public class FloorCeil
{
// Return the index of the largest item not larger than o.
public static int floor(Comparable [] l, Object o)
{
// TBD
}
// Return the index of the smallest item not smaller than o.
public static int ceil(Comparable[] l, Object o)
{
// TBD
}
// Test driver.
public static void main(String[] args)
{
Double[] l = new Double[100];
for (int i = 0; i < l.length; i++) {
l[i] = new Double(i);
}
System.out.println("Should print 20.0 : " +
l[floor(l, new Double(20.7))]);
System.out.println("Should print 71.0 : " +
l[ceil(l, new Double(70.8))]);
}
}
Explanation / Answer
public class FloorCeil { // Return the index of the largest item not larger than o. public static int floor(Comparable [] l, Object o) { for (int i = l.length-1; i >=0 ; i--) { if(l[i].compareTo(o)Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.