Thread: recursion
View Single Post
  #2 (permalink)  
Old 01-18-2008, 09:20 PM
CaptainMorgan's Avatar
CaptainMorgan CaptainMorgan is offline
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 841
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
You titled the thread "recursion", but didn't say whether you wanted to use it and I do not see your attempt at it. You also call a method findLargest, so I don't understand why you need the tester methods. The following compiles and runs - but I'm leaving the findLargest logic up to you - if you get stuck post how you've attempted it. Please use code tags.

Code:
public class ArrayTools { double[] doubs = new double[100]; double maximum; public ArrayTools(double[] myArray) { this.doubs = myArray; } public boolean tester() { return true; } private boolean tester(double i, int j) { return true; } public double findLargest() { // for all values k in doubs, // iterate over doubs[k], // compare next value to values already compared return maximum; } }
Code:
public class ArrayToolsTest{ public static void main(String[] args) { double[] myArray = { 1.2, 5.7, 4.3, 17.24, 12.34 }; // Fill this array with any doubles ArrayTools tester = new ArrayTools(myArray); System.out.println("The largest value in the array is " + tester.findLargest()); } }
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)
Reply With Quote