JAVA based on user input data to find a year to a certain number of days

Source: Internet
Author: User

Instance:

ImportJava.util.*;//How many days a year to a certain year Public classtest{ Public Static voidMain (string[] args) {Scanner in=NewScanner (system.in); System.out.println ("===== How many days a year to a certain year ====="); System.out.print ("Please enter the start year:"); intStart = In.nextint ();//gets the start year of user input        intrecord = 0;//record the number of times the user entered the end year        intEnd//declaration End year Variable         Do{System.out.print ("\ n"); if(record>=1) {System.out.print ("The end year cannot be less than the start year, please re-enter:"); }            Else{System.out.print ("Please enter the end year:"); } End= In.nextint ();//Gets the end year of user inputrecord++; }         while(end<start); intDate = 0;  for(intyear=start;year<end;year++){            if(year%4==0&&year%100!=0| | Year%400==0) {Date+ = 366; }            Else{Date+ = 365; }} System.out.println ("\ n" +start+ "year, to" +end+ "year Between:" +date+ "Day"); }}

Operation Result:

JAVA based on user input data to find a year to a certain number of days

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.