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

In this assignment, you will write a Java program using command line arguments.

ID: 3854322 • Letter: I

Question

In this assignment, you will write a Java program using command line arguments.

There is one method required: getMax, which takes two integer variables as input, returns the bigger one of the two.

Your main method must look like the following (except the comment)

. … main( String[] args)

{

int num1, num2;

num1 = Integer.parseInt(args[0]);

num2 = Integer.parseInt(args[1]);

System.out.println(“the bigger value of the two is : “ + getMax(num1, num2));

} .

Supply at least 3 testing results.

You program may work like:

java Assign5 23 67

the bigger value of the two is 67

Show the results too...

Explanation / Answer

public class MaxValue {

public static int getMax(int num1,int num2)

{

if(num1>num2)

{

return num1;

}

else

{

return num2;

}

}

public static void main(String[] args) {

// TODO Auto-generated method stub

int num1, num2;

num1 = Integer.parseInt(args[0]);

num2 = Integer.parseInt(args[1]);

System.out.println("the bigger value of the two is : " + getMax(num1, num2));

}

}