0% found this document useful (0 votes)
20 views

If Else If Ladder - Notes

Computer ICSE

Uploaded by

AnjuJohn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

If Else If Ladder - Notes

Computer ICSE

Uploaded by

AnjuJohn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

if else if ladder

Syntax:-
if (condition 1)
statement 1/block 1
else if (condition 2)
statement 2/block 2
else if (condition 3)
statement 3/block 3
- - - - - -- - - -- - - - - - -
----------------
else if (condition n-1)
statement n-1/block n-1
else
statement n
1) WAP to input a number in the range [1-7] and print the
corresponding day of the Week.
eg. 1- Monday , 2- Tuesday ……..7-Sunday
import java.util.*; public class if1

{public static void main()


{Scanner sc= new Scanner(System.in);
System.out.println("Enter a number in the range[1-7]:-");
int num=sc.nextInt();
if(num==1)
System.out.println("MONDAY");
else if(num==2)
System.out.println("TUESDAY");
else if(num==3)
System.out.println("WEDNESDAY");
else if(num==4)
System.out.println("THURSDAY");
else if(num==5)
System.out.println("FRIDAY");
else if(num==6)
System.out.println("SATURDAY");
else if(num==7)
System.out.println("SUNDAY");
else
System.out.println("SORRY ...NUMBER NOT IN THE SPECIFIED RANGE"); }}

You might also like