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 zeroExplanation / 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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.