The programmer must do 50 questions 4: enter a day of a certain year to determine the day of the year ?, 50 days
Package pwd;/*** the programmer must do 50 questions 4: enter a day of a certain year to determine the day of the year? * <P> @ author SunJian </p> * <p> date: January 1, October 20, 2017 </p> * <p> QQ: 330160114 </p> * <p> company: sihai xingtang </p> * <p> site: www.ccshxt.com </p> */public class DateCount {public static void main (String [] args) {// enter String input = "20171020" on the keyboard. // The day of the year int howManyDates = 0; // parse the year, month, and day int year = Integer. parseInt (input. substring (0, 4); int month = Integer. parseInt (input. substring (4, 6); int date = Integer. parseInt (input. substr Ing (6, 8); boolean run = false; // determines whether it is a leap year if (year % 100 = 0 & year % 4 = 0) & year % 400! = 0) {run = true;} for (int m = 1; m <month; m ++) {switch (m) {case 1: howManyDates + = 31; break; case 2: if (run) {// leap year, October day howManyDates + = 29;} else {// non-leap year, October day howManyDates + = 28;} break; case 3: howManyDates + = 31; break; case 4: howManyDates + = 30; break; case 5: howManyDates + = 31; break; case 6: howManyDates + = 30; break; case 7: howManyDates + = 31; break; case 8: howManyDates + = 31; break; case 9: howManyDates + = 30; break; case 10: howManyDates + = 31; break; case 11: howManyDates + = 30; break; case 12: howManyDates + = 31; break; default: System. out. println ("error") ;}} howManyDates = howManyDates + date; System. out. println (input + "is the" + year + "year" + howManyDates + "day ");}}