Java program for nested if-else else if statement
Java program for nested if-else else if statement
A programming language uses control statements to control the flow of execution of program based on certain conditions.
you can use one if or else if statement inside another if or else if statement.
![]() |
Nested else-if Program |
If none of the conditions is true, then the final else statement will be executed.
The final else acts as a default condition; that is, if all other conditional tests fail, then the last else statement is performed.
A program construct that is based upon a sequence of nested with if-else-if ladder
import java.util.Scanner;
class Story
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the Number:");
int a=sc.nextInt();
if(a%3==0&&a%5==0)
System.out.println("Virat WEDS Anushaka");
else if(a%3==0)
System.out.println("Virat");
else if(a%5==0)
System.out.println("Anushaka");
else
System.out.println("BREAKUP");
}
}
Comments
Post a Comment
Please do not write any spam link in the comment box.