> Online tutorial : if–then Statement in java
Showing posts with label if–then Statement in java. Show all posts
Showing posts with label if–then Statement in java. Show all posts

if–then Statement in java

The if–then Statement
I took an early opportunity of testing that statement . . .
An if–then statement is executed by first evaluating the Expression. If the result
is of type Boolean, it is subject to unboxing conversion . If evaluation of
the Expression or the subsequent unboxing conversion (if any) completes abruptly
for some reason, the if–then statement completes abruptly for the same reason.
Otherwise, execution continues by making a choice based on the resulting value:

• If the value is true, then the contained Statement is executed; the if–then
statement completes normally if and only if execution of the Statement completes
normally.
• If the value is false, no further action is taken and the if–then statement
completes normally.

Syntax:
if(conditional check)
{
executed code;
}
else
{
executed code;
}


Program
import java.io.*;
public class ifdat
{
public static void main(String args[])throws IOException
{
BufferedReader in=new BufferedReader(System.in);
InputStreamReader text=new InputStraemReader(in);
System.out.println("enter the salary");
String m=in.readLine();
int n=Integer.parseInt(m);
if(m<=1000) 
{
 int bon=m*.10;
 System.out.println("bonus"+bon);
 }
 else
 { 
int bon1=m*20;
 System.out.println("bonus"+bon1);
 }
 }
 }
Buy Java book