"Java" uses Zeller I consistency to calculate the day of the week

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.