|
|
|
The if-then-else statement provides a secondary path of execution when an "if" clause evaluates to false. You could use an if-then-else statement in the applyBrakes method to take some action if the brakes are applied when the bicycle is not in motion. In this case, the action is to simply print an error message stating that the bicycle has already stopped.
void applyBrakes(){
if (isMoving) {
currentSpeed--;
} else {
System.err.println("The bicycle has already stopped!");
}
}
If you need any urgent assistance on If-else-Statement, kindly email your requirement to us at : info@javagenious.com or Contact-an-Expert. Our experts will try their best to solve your problem.
Keyword Tags: If-else-Statement tutorial,If-else-Statement in java,Concepts of If-else-Statement,Java,J2EE,Interview Questions,If-else-Statement Examples
Most programming languages compile source code directly into machine code, suitable for execution on a particular microprocessor architecture. read more
|
|
|