email me at borlaj@portlandschools.org
notes previous (09/07/06) submit the dump links  
 

Array HW16 -

 

All of these will be made in application (the shell of which is below). The idea is that these are methods that are not called automatically, but when a user selects them in blueJ, or when they are called by another class. The methods are described below:

Starter code:


 
/**
 * Description - HWJ16 - To practice with int and string arrays
 * 
 * Author:
 * Date:
 */
public class HWJ16_MoreArray
{
    int nums[]={5,3,4,-8,15,-5,11,1,0,3};
    String fruits[] = {"cherry", "banana", "apple", "apricot"};

    /**
     * Adds X to each
     */
    public void addToEach(int x)
    {
        //enter your code here
    }

    /**
     * Prints values in num
     */
    public void printNums()
    {
        //enter your code here
    }        

    /**
     * finds the minimum value and returns it
     */
    public int findMin()
    {
        //enter your code here
        return 0;
    }  
    
    /**
     * finds the average value and returns it
     */
    public double findAvg()
    {
        //enter your code here
        return 0;
    }        

    /**
     * finds how many numbers are negative and returns it
     */
    public int findNumOfNegs()
    {
        //enter your code here
        return 0;
    }   

    /**
     * converts the array to all positive numbers
     */
    public void convertToPos()
    {
        //enter your code here
    }

    /**
     * looks for x and if it is in the array returns true, else false
     */
    public boolean contains(int x)
    {
        return false;
    }

    /**
     * Prints all fruit
     */
    public void printFruit()
    {
        //enter your code here
    }

    /**
     * Returns total number of letters in all fruit
     */
    public int totalLetters()
    {
        //enter your code here.
        return 0;
    }    

    /**
     * Advance Sorts the array, look at: http://www.javadb.com/how-to-sort-an-array
     */
    public void ADV_sortNums()
    {
        //enter your code here
    }

    /**
     * Advanced - Finds the median [the number in the middle when sorted].
     */
    public double ADV_findMedian()
    {
        //enter your code here
        return 0;
    }

    /**
     * Super advanced - updated the array so it holds another element.  The trick to this is create a new array one 
     * size longer and put in the old values and the additional one, then replace nums with that one (say nums=newNums)
     */
    public void SUPER_addElementToNums(int numToAdd)
    {
        //enter your code here
    }

	 /**
     * Advanced - Abbreviates each fruit to only 4 letters
     */
    public void abbreviateList()
    {
        //enter your code here
    }

    
    /**
    * Advanced - Prints out all fruit that start with the letter firstLetter
    */
    public void printSome(char firstLetter)
    {
        
    }
  
    
    /**
     * Advanced - Prints the fruit but capitalized use the String method .toUpperCase()
     */
    public void printCapitalizedFruit()
    {
        //enter your code here
    }

    /**
     * Advanced - finds the fruit with the longest name and returns it
     */
    public String ADV_findLongestFruit()
    {
        return "";
    }

    /**
     * [advanced]Have it say which word comes first alphabetically (use compareTo) [hard)
     */
    public String ADV_findFirstFruit()
    {
        return "";
    }
    


    /**
     * [advanced]Have it print out each word with every other letter capitalized. Like BaNaNa
     Hard show me you tried
     */
    public void SUPER_funnyCap()
    {

    }

    /**
     * Advanced - Have it return all values that are greater than x
     */
    public int[] findBigValues(int x)
    {
       return null;
    }

}