Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I got this program where i have to encode using hamming prettymuch got it but i

ID: 3617836 • Letter: I

Question

I got this program where i have to encode using hamming prettymuch got it but i am having big problems making a fuction that willtake as parameters an int that will be the number of skips or thenumber that need to be aquire from arraylist.  Alsoskip is the number from which we will start reading from arraylist Example lets say that skip=1 and the array list is 1 2 3 4 5 6 7 8 the fuction would aquire 1 and then skip 2 then aquire 3 thenskip 4 so it would out put 1 3 4 7 9 so on so on Example two lets say skip=2 and the array list is 1 2 3 4 5 6 7 8 9 then the function would aquire 2, 3 and then skip 4, 5 thenaquire 6, 7 so on so on so it would output 2,3,6,7 so on so on I got this program where i have to encode using hamming prettymuch got it but i am having big problems making a fuction that willtake as parameters an int that will be the number of skips or thenumber that need to be aquire from arraylist.  Alsoskip is the number from which we will start reading from arraylist Example lets say that skip=1 and the array list is 1 2 3 4 5 6 7 8 the fuction would aquire 1 and then skip 2 then aquire 3 thenskip 4 so it would out put 1 3 4 7 9 so on so on Example two lets say skip=2 and the array list is 1 2 3 4 5 6 7 8 9 then the function would aquire 2, 3 and then skip 4, 5 thenaquire 6, 7 so on so on so it would output 2,3,6,7 so on so on

Explanation / Answer



public static void skip(int x){    System.out.println("skip "+x+" ..."); }
If you mean for the main, then:
/** Run using a command like: java myClass arg1 agr2 */ public static void main(String[] arguments){ //recommend try/catch or you will get an exception when youenter a non-number String s=arguments[1]; skip(num1);
int num2; try{ num2= new Integer( arguments[2]); }catch(Exception e){ e.printStackTrace(); }
}
Also checkout Integer.parseInt(), Double.parseDouble, etc.Java has very good reference material. Look at it for a list offunctions and usage. http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Integer.html
Also, use Netbeans to simplify everything. It is very easy touse. int num2; try{ num2= new Integer( arguments[2]); }catch(Exception e){ e.printStackTrace(); }
}
Also checkout Integer.parseInt(), Double.parseDouble, etc.Java has very good reference material. Look at it for a list offunctions and usage. http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Integer.html
Also, use Netbeans to simplify everything. It is very easy touse.