Friday, 13 September 2013

multiple if else statement using java


import java.util.*;

public class Condition {

    public static void main(String[] args) {
      int a[]= new int[1] ;
            Scanner sc=new Scanner(System.in);
            System.out.println("Please enter elements between 0 and 6");
            for(int j=0;j<1;j++)
                a[j] = sc.nextInt();

            for(int j=0;j<1;j++)
                if(a[j]==0)
                {
                System.out.println("Sunday!");
                 break;}
                else if(a[j]==1)
                {
                    System.out.println("Monday!");
                 break;}
                else if(a[j]==2)
                {
                System.out.println("Tuesday!");
                 break;}
                else if(a[j]==3)
                {
                    System.out.println("Wednesday!");
                 break;}
                else if(a[j]==4)
                {
                System.out.println("Thursday!");
                break; }
                 else if(a[j]==5)
                {
                    System.out.println("Friday!");
                 break;}
                else if(a[j]==6)
                {
                System.out.println("Saturday!");
                 break;}
                else
                {
                System.out.println("Sorry Invallid option! Enter the number between the range 0 to 6");
              break;  }
          
                          
    }
}