Do not rely on the System class Java calendar, Skull Halo.
Source: Internet
Author: User
Package test2;
Import Java.util.Scanner;
public class Demo {
public static void Main (String args[]) {
Scanner input=new Scanner (system.in);
Boolean in1=false;
Boolean in2=false;
int year;
int month;
int year_day=0;
int month_day=0;
int day_count;
int week;//days a week
int month_days=0;
int space=0;
int C;
int ln=1;//A counter that starts wrapping as the second line of output
do{
System.out.println ("Please enter Year:");
Year=input.nextint ();
if (year<0) {
SYSTEM.OUT.PRINTLN ("Year input error, please re-enter");
In1=true;
}else{in1=false;}
}while (in1);
do{
System.out.println ("Please enter the month:");
Month=input.nextint ();
if (month>12| | month<1) {
SYSTEM.OUT.PRINTLN ("Month input error, please re-enter");
In2=true;
}else{in2=false;}
}while (in2);
The/*for Loop calculates the number of days between the year_day of 1900 and the year in which it was entered.
for (int a=1900,day;a<year;a++) {
if ((a%4==0&a%100!=0) |a%400==0) {
day=366;
}else{day=365;}
Year_day=year_day+day;
}
/*for cyclic computation of the first month_day, that is, the number of days before the year January to the entered month (month) * *
for (int b=1;b<month;b++) {
Switch (b) {
Case 1:case 3:case 5:case 7:case 8:case 10:case 12:
month_day=month_day+31;
Break
Case 4:case 6:case 9:case 11:
month_day=month_day+30;
Break
Case 2:
if ((year%4==0&year%100!=0) |year%400==0) {
month_day=month_day+28;
}
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.