当前位置:网站首页>Slag learning path (1) output the calendar page of a certain month of a certain year
Slag learning path (1) output the calendar page of a certain month of a certain year
2022-07-19 06:49:00 【Did you learn to waste today】
Java Output the calendar page of a year and a month
Input the date through the keyboard, and output the calendar page in the transfer function :
package dy;
import java.util.Calendar;
import java.util.Scanner;
public class DDy{
public static void main(String args[]){
Scanner in=new Scanner(System.in);
System.out.println(" Please enter the year :");
int year=in.nextInt();
System.out.println(" Please enter the month :");
int month=in.nextInt();
in.close();
Calendar The calendar =Calendar.getInstance();
The calendar .set(year,month,1);
int What day = The calendar .get(Calendar.DAY_OF_WEEK)-1;
int day=0;
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12){
day=31;
System.out.println(" Total in this month :"+day+' God ');
}
else
if(month==4||month==6||month==9||month==11){
day=30;
System.out.println(" Total in this month :"+day+' God ');
}
else
if(month==2){
if(year%4==0&&year%100!=0||year%400==0){
day=29;
System.out.println(" Total in this month :"+day+' God ');
}
else
day=28;
System.out.println(" Total in this month :"+day+' God ');
}
String c[]=new String[ What day +day];
for(int j=0;j< What day ;j++){
c[j]="";
}
for(int j= What day ,n=1;j< What day +day;j++){
c[j]=String.valueOf(n);
n++;
}
System.out.printf("%14c%14c%14c%14c%14c%14c%14c\n",' Japan ',' One ',' Two ',' 3、 ... and ',' Four ',' 5、 ... and ',' 6、 ... and ');
for(int j=0;j<c.length;j++){
if(j%7==0&&j!=0)
System.out.printf("\n");
System.out.printf("%5s",c[j]);
}
}
}
边栏推荐
猜你喜欢

Restapi implements aggregation (dark horse tutorial)

Temperature acquisition experiment and experimental experience based on I2C

F5 GTM(一):DNS参数

DSL implements metrics aggregation

Share the application cases of CS brand patch T card in the field of hunting camera

DSL implements bucket aggregation

用Altium Designer绘制PCB图

Restclient query document

Wu Enda machine learning chapter 14-15

Information on successful cooperation between CS brand sdnand and stm32mcu
随机推荐
Wu Enda machine learning chapter 6-7
Dual tone sorting of CUDA and large arrays
高并发day01(NIO、ConCurrent包)
Wu Enda machine learning chapter 14-15
Part of the second Shanxi Network Security Skills Competition (Enterprise Group) WP (IV)
Query of database (II)
《PyTorch深度学习实践》-B站 刘二大人-day5
redis
Part of the second Shanxi Network Security Skills Competition (Enterprise Group) WP (I)
sql的约束条件
Openssl--- stack
BigDecimal中divide方法
Release nohup Out disk space occupied
OLED data display based on spi/iic interface
Restapi implementation of automatic completion & case implementation (search box input for automatic completion)
关于STM汇编程序设计相关学习
渣渣学习之路(1)输出某年某月的日历页
Experiment 3 inheritance and derived classes
redis
企业数据治理之勒索病毒篇