日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java简易日历程序报告_简单的日历小程序(java编写)

發布時間:2023/12/4 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java简易日历程序报告_简单的日历小程序(java编写) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

import java.util.Scanner;

public class CalendarDemo{

public static void main(String[] args) {

int sum = 0;

Scanner in = new Scanner(System.in);

System.out.print("請輸入年份:");

int year = in.nextInt();

Scanner sc = new Scanner(System.in);

System.out.print("請輸入月份:");

int month = sc.nextInt();

for (int i = 1900; i <= year; i++) {

if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {

sum += 366;

} else {

sum += 365;

}

}

for (int i1 = 1; i1 <= month; i1++) {

if (i1 == 2) {

if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {

sum += 29;

}

/*

* for(int i=1;i<=29;i++){ if(sum%7==6){

* System.out.print(i+"\n"); } else{

* System.out.print(i+"\t"); } sum++; break; }

*/

else{

sum += 28;

}

/*

* for(int i=1;i<=28;i++){

*

* if(sum%7==6){ System.out.print(i+"\n"); } else{

* System.out.print(i+"\t"); } sum++; break;

*? }

*/

} else if (i1 == 1 || i1 == 3 || i1 == 5 || i1 == 7 || i1 == 8

|| i1 == 10 || i1 == 12) {

sum += 31;

/*

* for(int i=1;i<=31;i++){ if(sum%7==6){

* System.out.print(i+"\n"); } else{ System.out.print(i+"\t"); }

* sum++; break; }

*/

} else {

sum += 30;

/*

* for(int i=1;i<=30;i++){ if(sum%7==6){

* System.out.print(i+"\n"); } else{ System.out.print(i+"\t"); }

* sum++; break; }

*/

}

}

sum += 1;

System.out.println("從1900年1月1日到"+year+"年"+month+"月1日總共是"+sum+"天");

System.out.println("從1900年1月1日到"+year+"年"+month+"月1日是星期"+(sum%7));

int weekday;

weekday = sum % 7;

System.out.println("日\t一\t二\t三\t四\t五\t六");

for (int i = 1; i <= weekday; i++) {

System.out.print("\t");

}

if(month==2){

if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0){

for (int i = 1; i <= 29; i++) {

if (sum % 7 == 6) {

System.out.print(i + "\n");

} else {

System.out.print(i + "\t");

}

sum++;

continue;

}

}

else{

for (int i = 1; i <= 28; i++) {

if (sum % 7 == 6) {

System.out.print(i + "\n");

} else{

System.out.print(i + "\t");

}

sum++;

continue;

}

}

}

else if(month==4||month==6||month==9||month==11){

for (int i = 1; i <= 30; i++) {

if (sum % 7 == 6) {

System.out.print(i + "\n");

} else {

System.out.print(i + "\t");

}

sum++;

continue;

}

}

else{

for (int i = 1; i <= 31; i++) {

if (sum % 7 == 6) {

System.out.print(i + "\n");

} else {

System.out.print(i + "\t");

}

sum++;

continue;

}

}

}

}

/* public static void main(String[] args){ Calendar cal= Calendar.getInstance();

* int a=cal.get(Calendar.YEAR); if(a%4==0&&a%100!=0||a%400==0){

* System.out.println(a+"是閏年"); }else System.out.println(a+"不是閏年"); } }

*/

總結

以上是生活随笔為你收集整理的java简易日历程序报告_简单的日历小程序(java编写)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。