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

MODIFY THE PROGRAM BELOW BY FOLLOWING THE DIRECTION.. --------------------------

ID: 3698944 • Letter: M

Question

MODIFY THE PROGRAM BELOW BY FOLLOWING THE DIRECTION..

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

public class Num3 {

public static void doIt(int x) {

}

public static void main(String[] args) {

System.out.println("your name here");

doIt(-2);

doIt(44);

doIt(0);

}

}

Modify this program as follows: Output your first and last name Add code to the dolt method that: Outputs "negative" if the input parameter is less than zero Outputs "positive" if the input parameter is greater than zero Outputs "zero" if the input parameter is zero Command Prompt your name here negative positive zero

Explanation / Answer

Num3.java

public class Num3 {

public static void doIt(int x) {

if(x < 0) {

System.out.println("negative");

} else if(x>0){

System.out.println("positive");

}else {

System.out.println("zero");

}

}

public static void main(String[] args) {

System.out.println("your name here");

doIt(-2);

doIt(44);

doIt(0);

}

}

Output:

your name here
negative
positive
zero