Java 小日历格式输出 闰年计算
2010-04-26 22:36
import java.util.Scanner;
public class _calendar {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("请输入年份:");
Scanner sc = new Scanner(System.in);
int year = sc.nextInt();
if (year < 1900) {
System.out.println("请输入大于1900年的年份:");
year = sc.nextInt();
}
System.out.println("请输入月份:");
int month = sc.nextInt();
if (month < 0 || month > 12) {
System.out.println("请输入正确月份(1-12):");
month = sc.nextInt();
}
System.out.println("年份:" + year + ",月份:" + month);
/* 判断是否是闰年 */
boolean y = run_count(year);
System.out.println();
/*
* if((year%4==0)&&(year%100!=0)||(year%400==0)) {
* System.out.println("该年份是闰年!"); y=true; } else { y=false;
* System.out.println("该年份不是闰年!"); }
*/
/* 计算输入月份的天数 */
int day;
day = day_count(y, month);
/*
* { if((y==true)&&(month==2)) { day=29;
* System.out.println("该年月份下,月份:"+day+"天"); } else
* if((y==false)&&(month==2)) { day=28;
* System.out.println("该年月份下,月份:"+day+"天"); } else
* if((month==4)||(month==6)||(month==9)||(month==11)) { day=30;
* System.out.println("该年月份下,月份:"+day+"天"); } else {day=31;
* System.out.println("该年月份下,月份:"+day+"天");}}
*/
/* 计算该月第一天是星期几 */
/* 1、计算输入年份距离1900年1月1日的天数 */
int run = 0;// 输入年份距1900之间有多少闰年
for (int x = 1900; x < year;
相关文档:
第一部分:Java虚拟机启动时,关于类加载方面的一些动作
当使用java ProgramName.class运行程序时,Java找到JRE,接着找到jvm.dll,把该动态库载入内存,这就是JVM。然后加载其它动态库, 并激活JVM。JVM激活之后会进行一些初始化工作,之后生成BootstrapLoader,该Class Loader是由C++写的。BootstrapLoader加载Launche ......
好久没用java,突一写起来,发现机器上没有设置环境变量,把设置方法总结一下
1. 修改/etc/profile文件
如果你的计算机仅仅作为开发使用时推荐使用这种方法,因为所有用户的shell都有权使用这些环境变量,可能会给系统带来安全性问题。
·用文本编辑器打开/etc/profile
·在pr ......
http://hi.baidu.com/0_net/blog/item/8566fc2bb730c293033bf63e.html
一.获得控制台用户输入的信息
/** *//**获得控制台用户输入的信息
* @return
* @throws IOException
*/
public St ......
用的是MySQL数据库。
1,建一个userdb库,再建userinfo表,字段:id(int),username(varchar),password(varchar)。
create database userdb;
use userdb;
create table userinfo(
id int(10) not null auto_increment,
username varchar(20),
password varchar(20),
primary key(id));
2,DBConnection.jav ......