(每日一java)PrintCalendar

本文介绍了一个使用Java编写的简单程序,该程序可以接收用户输入的年份和月份,并打印出对应月份的日历。程序利用了Scanner类来获取用户的输入,并通过自定义的方法实现日历的打印。
//第五章  143页
import java.util.Scanner;
public class PrintCalendar { 
	/*main method */
	public static void main (String[] args)  {
		Scanner input = new Scanner  (System.in);
		
		//prompt the user to enter year
		System.out.print("Enter full year (e.g., 2001): ");
		 int year = input .nextInt();
		 
		 //prompt the user to earn month 
		 System.out.print("Enter month as number between 1 and 12: ");
		 int month = input.nextInt();
		 
		 //Print calendar for the month of year
		 printMonth (year, month);
	}
	
	//A stub for printMonth may look like this 
	public static void printMonth(int year, int month) {
		System.out.print(month + " "  + year);
	}
	
	//A stub for printMonth may look like this 
	public static void printMonthTitle(int year, int month) {
	}
	
	//A stub for getMonthTitle may look like this 
	public static void printMOnthBody( int year, int month ){
	}
	
	//  A stub for getMonthName may look like this 
	public static String getMontName(int month){
	return "juanuary"; 
	}
	
	//A stub for getMonthName may look like this 
	public static int getStartDay (int year, int month) {
		return 1;
	}
	
	// A stub for getTitaNumberOfDays may look like this 
	public static int getTotalNumberOfDays(int year, int moth) {
		return 10000;
	}
	
	// S stub for getNumberOfDaysInMonth may look like this 
	public static int getNumberOfDaysInMonth (int year, int month) {
		return 31;
		}
	
	//A stub for getTotalNumberOfDay may look like this 
	public static boolean isLeapYear(int year ) {
		return true; // A dummy value
	}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值