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