Respuesta :
Answer:
//Scanner class is imported to allow the program receive user input
import java.util.Scanner;
//The class is defined by name UserNums
public class UserNums {
//The main method which signify the beginning of program execution
public static void main (String [] args) {
//Scanner object 'scan' is created
Scanner scan = new Scanner(System.in);
// prompt the user to enter first number
System.out.println("Enter first number:");
//first number is assigned to userNum1
int userNum1 = scan.nextInt();
// prompt the user to enter second number
System.out.println("Enter second number:");
//second number is assigned to userNum2
int userNum2 = scan.nextInt();
// userNum1 = 1;
// userNum2 = 14;
//Print userNum1 is negative if userNum1 is less than zero
if (userNum1 < 0){
System.out.println("userNum1 is negative.");
}
//Convert userNum2 to zero if userNum2 is greater than 11
if (userNum2 > 11){
userNum2 = 0;
System.out.println("userNum2 has been converted to 0.");
} else {
System.out.println("userNum2 is less than or equal to 11.");
}
}
}
Explanation:
Answer:
if (userNum1 < 0 ){
System.out.println("userNum1 is negative.");
}
if (userNum2 > 11){
userNum2 = 5;
}
else {
System.out.println("userNum2 is less than or equal to 11.");
}
Explanation:
Just changed the numbers to fit with your question. Code is the same though.