Based on the month and day entered, the day of the year is calculated.

Source: Internet
Author: User

 Packagestudy01;ImportJava.util.Scanner; Public classTestday {/** Enter 2017 year month and day: month=?,day=? The date of the output input is the day of 2017, using switch to complete*/     Public Static voidMain (string[] args) {Scanner sc=NewScanner (system.in); System.out.print ("Month="); intmonth =Sc.nextint (); System.out.print ("Day="); intDay =Sc.nextint (); intDays = 0; Switch(month) { Case12: Days+ = 30;  Case11: Days+ = 31;  Case10: Days+ = 30;  Case9: Days+ = 31;  Case8: Days+ = 31;  Case7: Days+ = 30;  Case6: Days+ = 31;  Case5: Days+ = 30;  Case4: Days+ = 31;  Case3: Days+ = 28;  Case2: Days+ = 31;  Case1: Days+=Day ; }        if(days>365) {System.out.println ("You've entered it for more than 365 days."); }Else{System.out.println ("First" + Days + "Day"); }    }}


The results of the output are as follows:

Month=12
Day=31
No. 365 Day




Based on the month and day entered, the day of the year is calculated.

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.