Posts

Showing posts from June 21, 2015

An algorithm for calculating the day of the week given a Date

Given a date and calculate day of the week: i mport java.util.*; public class Datetoday {        final static String[] WEEK_DAYS = {            "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",            "Friday"        };    public static void main(String[] args) {        Scanner input = new Scanner(System.in);        System.out.print("Enter the date in dd/mm/yyyy form: ");        String[] partofdate = input.nextLine().split("/");        int d = Integer.parseInt(partofdate[0]);        int m = Integer.parseInt(partofdate[1]);      ...