5-2 WeekDays

Post date: Apr 2, 2014 7:35:30 PM

package weekdayes;

import java.util.Scanner;

public class WeekDayes 

{

        public static void main(String[] args) 

        {

            Scanner scan=new Scanner(System.in);

            System.out.println("Enter the weekday : ");

            System.out.println(weekdayName(scan.nextInt()));

        }

        

       /* The following method, for example, 

        returns the English name of the day of the week, given a number between 1 (Sunday) and 7 (Saturday):*/

        

        public static String weekdayName(int day)

        { 

            switch (day) 

            { 

             case 1: return "Sunday"; 

             case 2: return "Monday"; 

             case 3: return "Tuesday"; 

             case 4: return "Wednesday"; 

             case 5: return "Thursday"; 

             case 6: return "Friday"; 

             case 7: return "Saturday"; 

             default: return "Illegal value"; 

            }

       }

}