- import java.util.Scanner;
- public class C1
- {
- public static void main(String[] args)
- {
- Scanner input = new Scanner(System.in);
- //提示使用者輸入年份和當年第一天資訊
- System.out.println("使用者輸入:");
- String year = input.next();
- int a = input.nextInt();
- int i;
- int count = a + 1;
- //印出月曆抬頭
- System.out.println(year+"年1月份");
- System.out.println("Sun" + " " + "Mon" + " " + "Tue" + " " + "Wed" +
- " " + "Thu" + " " + "Fri" + " " +"Sat");
- //設定該年一月月曆是從星期幾開始
- if( a == 1 )
- {
- System.out.print(" ");
- }
- if( a == 2)
- {
- System.out.print(" " + " " );
- }
- if( a == 3)
- {
- System.out.print(" " + " " + " " );
- }
- if( a == 4)
- {
- System.out.print(" " + " " + " " + " ");
- }
- if( a == 5)
- {
- System.out.print(" " + " " + " " + " " + " ");
- }
- if( a == 6)
- {
- System.out.print(" " + " " + " " + " " + " " + " ");
- }
- //輸出結果
- for( i=1 ; i <= 31 ; i++ )
- {
- if(count % 7 == 1 )
- {
- System.out.printf("\n%3d",i); //在這裡會換行
- }
- else if(count % 7 == 0)
- {
- System.out.printf("%5d",i);
- }
- else if(count % 7 == 2)
- {
- System.out.printf("%5d",i);
- }
- else if(count % 7 == 3)
- {
- System.out.printf("%5d",i);
- }
- else if(count % 7 == 4)
- {
- System.out.printf("%5d",i);
- }
- else if(count % 7 == 5)
- {
- System.out.printf("%5d",i);
- }
- else if(count % 7 == 6)
- {
- System.out.printf("%5d",i);
- }
- count = count + 1 ;
- }
- }
- }
2014年7月12日 星期六
java程式設計題目---日期處理【印製月曆(一月)】
請設計一個程式可以印製某一年一月的月曆,請使用者輸入年份及當年第一天(1月1日)是星期幾,其中0代表星期日,1至6分別代表星期一至星期六。範例如下:
訂閱:
張貼留言 (Atom)
Go(Golang)程式語言 設定GCC
下載MSYS2: https://www.msys2.org/ 安裝 程式開始執行後輸入: pacman -Syu y y 在安裝目錄底下找到msys2.exe,雙擊執行 輸入指令: pacman -Su pacman -S --needed base-devel mingw-...
-
MNIST手寫數字辨識資料集 MNIST手寫數字辨識資料集 ,是由 Yann LeCun(揚·勒丘恩) 大神所蒐集,這位大神同時也是Convulution Nueral Networks(卷積神經網絡)的創始人,因此享有"卷積網絡之父"的美譽。關於這位大...
-
Write a program that reads an integer between 100 and 999, and show the result of the sum, product and difference of all its digits. For ex...
-
設計一程式,提示使用者輸入正整數n,判斷此數是否為質數並將結果印出。
沒有留言:
張貼留言