min's devlog
Java 달력 만들기 본문
int year = 2022;
int month = 3;
int lastDay = getLastDay(year, month);
int dayOfWeek = getDayOfWeek(year, month);
System.out.println("====================================================");
System.out.printf(" %d년 %d월\n", year, month);
System.out.println("====================================================");
System.out.println("[일]\t[월]\t[화]\t[수]\t[목]\t[금]\t[토]");
System.out.println("====================================================");
for (int i=0; i<dayOfWeek; i++) {
System.out.print("\t");
}
for (int i=1; i<=lastDay; i++) {
System.out.printf("%3d\t", i);
//토요일 개행
if ((i + dayOfWeek) % 7 == 0) {
System.out.println();
}
}
'til > Java' 카테고리의 다른 글
메소드(Method) (0) | 2022.03.20 |
---|---|
jar와 특수문자(Escape) (0) | 2022.03.20 |
연산자(Operator) (0) | 2022.03.10 |
형변환(Casting) (0) | 2022.03.08 |
Output과 Input (0) | 2022.03.08 |
Comments