Answer:
import java.util.Scanner;
public class UpdateNumberOfUsers {
public static void main (String [] args) {
int numUsers = 0;
int updateDirection = 0;
numUsers = 8;
updateDirection = 1;
if(updateDirection==1){
numUsers++;
}else{
numUsers--;
}
System.out.println("New value is: " + numUsers);
return;
}
}
Explanation:
Conditional statement is the statement which used to check the condition, if condition is TRUE then execute the statement otherwise not execute.
if else is the Conditional statement which used in the programming.
According to question, if updateDirection == 1, then increment numUsers , otherwise decrement.
these are the condition which can put in the if else statement:
if(updateDirection == 1)
{
numUsers++; //increment
}else{
numUsers--; //decrement
}