I'm learning java and some parts are really confusing while other parts I can catch on immediately. Below is some of the methods i have to find the results for. but i don't quite understand. I really would appreciate the help to dissecting the method so i can learn whats going on. Thanks
1)Add user input via Scanner to main that calls each method.
2)Output the results of calling each method, this is not as straightforward for the third method.
3)For each method, make a new version that takes in String for the first parameter instead of an integer. You will probably have to change the return type as well. Test each of these methods and both show and explain how they are different from the original methods.
public class Hw3
{
public static void main(String[] args)
{
// Stuff goes here.
}
public static int hw3_method1(int a, int b)
{
for(int i=0; i<b; i++)
{
System.out.printf("%s%3d%s %4d%s\n", "|", i, "|", a, "|");
}
return a;
}
public static int hw3_method2(int a, int b)
{
int retval = 0;
for(int i=0; i<b; i++)
{
retval += a;
}
return retval;
}
public static int[] hw3_method3(int a, int b)
{
int[] retval = new int[b];
for(int i=0; i<b; i++)
{
retval[i] = (i+a);
}
return retval;
}
// You will need to change what is here.
// You will also need to add stuff.
public static int hw3_method1_modified()
{
return 0;
}
public static int hw3_method2_modified()
{
return 0;
}
public static int[] hw3_method3_modified(int a, int b)
{
return new int[1];
}
}