• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java help (Methods) Practice  RSS feed

 
Micheal Hallow
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Methods to be implemented]

Method: fillArray

the method accepts a non-null String variable as an argument. Return a char array that has been filled from the String passed to the method, each element set to the corresponding character in the string. public char[] fillArray(String var)

Method: stringArray

the method accepts an array of chars as an argument if the chArray is null or length is zero, returns an empty string if chArray is not null, return a single string with each of the characters in the array in the string. public String stringArray(Char[] chArray)

Method: productMatrix 0 <= n <= 100 if n is out of bounds, return null if n is greater than or equal to zero, return a n x n matrix with each element of the matrix set to row index * column index. public int [] [] productMatrix(int n)

Method: sumOfSquares the method accepts an array of ints if the array is null or of size zero, return 0 if the size of the array is greater than or equal to 1 return an int equal to the sum of the square of each element of the array public long sumOfSquares(int[] intArray)

Method: incPosArray the method accepts an array of ints if the array is null or of size zero, simply return if the size of the array is greater than or equal to 1 increment each positive element of the array, leaving the negative elements and the elements equal to zero set to their incoming values public void incPosArray(int[] intArray)

public class Q3 {

/*
* Method: fillArray
*/
public char[] fillArray(String var){
    System.out.println( "fillArray not implemented");
    return null;
}

/*
* Method: stringArray
*/
public String stringArray(char[] chArray) {
    System.out.println( "stringArray not implemented");
    return null;
}

/*
* Method: productMatrix
*/
public int[][] productMatrix(int n){
    System.out.println( "productMatrix not implemented");
    return null;
}

/*
* Method: sumOfSquares
*/
public long sumOfSquares (int[] intArray) {
    System.out.println( "sumOfSquares not implemented");
    return -1;
}

/*
* Method: incPosArray
*/
public void incPosArray (int[] intArray) {
    System.out.println( "incPosArray not implemented");
    return;
}


public static void main (String[] args) {
    Q3 q3 = new Q3();

    //Put your test code here

}
}

 
Micheal Hallow
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing showed up from that link?
 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Micheal, welcome to the Ranch!

I'm not sure what you mean by "that link". But anyway you seem to have posted a homework assignment, am I right? So do you have questions about it? Please bear in mind that people here aren't going to do your work for you, but clarification of your questions are okay and so are hints. But you have to start by asking something.
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again

I suggest you change all your unimplemented methods to what NetBeans would write:-Note you cannot write a return statement until after you delete the throw statement when you complete the method. Precede your methods with proper documentation comments starting /** and delete comments which only tell us the name of the method. The documentation comments should include information about whether nulls are permitted.

I suggest you start with one method from those instructions and write down how you think you are going to implement it.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!