IN JAVA
Print "userNum1 is negative." if userNum1 is less than 0. End
with newline.
Convert userNum2 to 0 if userNum2 is greater than 10. Otherwise,
print "userNum2 is less than or equal to 10.". End with
newline.
public class UserNums {
public static void main (String [] args) {
int userNum1;
int userNum2;
userNum1 = 0;
userNum2 = 7;
*insert*
System.out.println("userNum2 is " + userNum2);
}
}
import java.util.Scanner;
public class UserNums {
public static void main (String [] args) {
int userNum1;
int userNum2;
Scanner in = new Scanner(System.in);
userNum1 = in.nextInt(); // Making the program general for input output checks
userNum2 = in.nextInt(); // Making the program general for input output checks
if(userNum1 < 0){
System.out.println("userNum1 is negative.");
}
if(userNum2 <= 10){
System.out.println( "userNum2 is less than or equal to 10.");
}
else if(userNum2 > 10){
userNum2 = 0;
}
System.out.println("userNum2 is " + userNum2);
}
}
Get Answers For Free
Most questions answered within 1 hours.