1 /**2 * Created by Liangjiahao on 2017/2/26.3 * Use Zeller I consistency to calculate the day of the week? 4 * Formula:5 * H = (q + (m+1)/10 + k +K/4 + J/4 +5j)% 76 * 7 */8 9 Ten ImportJava.util.Scanner; One Public classZeller { A Public Static voidMain (String args[]) { -Scanner imput =NewScanner (system.in); - theSystem.out.print ("Enter a year: (e.g, 2012):"); - intYear =imput.nextint (); - -System.out.print ("Enter a mouth:1-12:"); + intmouth =imput.nextint (); - +System.out.print ("Enter the day of the mouth:"); A intDay =imput.nextint (); at - intTempmouth = mouth;//January, February, 13, 14, year of last year - Switch(Tempmouth) { - Case1:mouth = 13; Year-=1; Break; - Case2:mouth = 14; Year-=1; Break; - } in - intCentury = year/100; to intYearofcentury = year% 100; + - intThedayis = (Day + * (mouth + 1)/ten + Yearofcentury + YEAROFCENTURY/4 + CENTURY/4 + 5 * century)% 7; the //0 for weeks 61 for Sunday 2 for Week 13 for week 24 for week 35 for week 46 for Friday * Switch(thedayis) { $ Case0:system.out.println ("Day of the Week is Saturday"); Break;Panax Notoginseng Case1:system.out.println ("Day of the Week is Sunday"); Break; - Case2:system.out.println ("Day of the Week is Monday"); Break; the Case3:system.out.println ("Day of the Week is Tuesday"); Break; + Case4:system.out.println ("Day of the Week is Wednesday"); Break; A Case5:system.out.println ("Day of the Week is Thursday"); Break; the Case6:system.out.println ("Day of the Week is Friday"); Break; + } - $ } $}
"Java" uses Zeller I consistency to calculate the day of the week