Traditional Culture Encyclopedia - Almanac inquiry - How to write Java yearbook
How to write Java yearbook
/**
*
*/
Package calendar;
Import java.util.scanner;
/**
* perpetual calendar
*
* @ Author Administrator
*
*/
Open class calendar {
/**
* @param args
*/
Public static void main(String[] args) {
Scanner input = new scanner (system. in);
System.out.print ("Please enter year:");
int year = input . nextint();
System.out.print ("Please enter the month:");
int months = input . nextint();
int yearn um = 0;
int sum = 0;
for(int I = 1900; My< year; I++){// year
if((I % 4 = = 0)| |(I % 100! = 0 & amp& ampI % 400 = = 0){
sum+= 366;
} Otherwise {
sum+= 365;
}
}
boolean isYear = false
If ((year% 4 = = 0)| | (year% 100! = 0 & amp& ampyear % 400 = = 0){
isYear = true
}
for(int I = 1; I < = month; I++){// month
sum+= yearn um;
Switch (I ){ (
Case 1:
Case 3:
Case 5:
Case 7:
Case 8:
Case 10:
Case 12: {
yearn um = 3 1;
Break;
}
Case 4:
Case 6:
Case 9:
Case 1 1: {
yearNum = 30
Break;
}
Case 2: {
if(is year ){
yearNum = 29
} Otherwise {
yearNum = 28
}
Break;
}
}
}
String [] week = {Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday};
for(int I = 0; I & ltweek. Length; i++) {
system . out . print(week【I】+“\ t“);
}
system . out . println();
for(int I = 0; I < total% 7; i++) {
system . out . print(“\ t“);
}
for(int n = 1; N< = yearumn++) {//output
if((sum+n)% 7 = = 1 ){
system . out . println();
}
system . out . print(n+“\ t“);
}
}
}
- Previous article:Dream of buying a pair of red underwear.
- Next article:Romantic love story about a girl moved to tears (38 selected sentences)
- Related articles
- Male: solar calendar 65438+ lunar calendar 65438 June 3, 0984+early May 4, 0984 ... Female: 65438+ March 24, 09841February 22, 984. I want to ask, a good day to get married.
- Dream and people travel far.
- How to pick up the car in the summer of 2022? Is it appropriate to buy a car to go home?
- How about opening on June 8, 2023? Is it auspicious to open on this day?
- How about caesarean section on July 4, 2022?
- Birthday wedding date selection software, birthday wedding date selection.
- Don't bring pronunciation when you charge credit.
- What are the legal holidays for the National Day in 2020?
- It is accurate to find someone to read the almanac.
- Where did the god of wealth put his face?