网站建设资讯

NEWS

网站建设资讯

租房java代码,程序员租房代码

Java编程,填写下面的代码

class NoLowerLetterException extends Exception {

创新互联建站-专业网站定制、快速模板网站建设、高性价比额敏网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式额敏网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖额敏地区。费用合理售后完善,10多年实体公司更值得信赖。

public NoLowerLetterException(String msg) {

super(msg);

}

}

class NoDigitException extends Exception {

public NoDigitException(String msg) {

super(msg);

}

}

class People {

void printLetter(char c) {

if (c = 'a' c = 'z') {

System.out.println(c);

} else {

try {

throw new NoLowerLetterException(String.valueOf(c));

} catch (NoLowerLetterException e) {

e.printStackTrace();

}

}

}

void printDigit(char c) {

if (c = '0' c = '9') {

System.out.println(c);

} else {

try {

throw new NoDigitException(String.valueOf(c));

} catch (NoDigitException e) {

e.printStackTrace();

}

}

}

}

public class ExceptionExample {

public static void main(String args[]) {

People people = new People();

for (int i = 0; i 128; i++) {

// 【代码5】

// //将i转换为char类型,执行people.printLetter()方法,如果出现异常则捕获,并输出异常的错误信息!

people.printLetter((char) i);

}

for (int i = 0; i 128; i++) {

// 【代码6】 //将i转换为char类型,执行people. printDigit

// ()方法,如果出现异常则捕获,并输出异常的错误信息!

people.printDigit((char) i);

}

}

}

java 代码怎么写?

package com.date;

public class DateDome {

private int year=0;//年

private int month=0;//月

private int day=0;//日

public DateDome(int year,int month,int day){

this.year=year;

this.month=month;

this.day=day;

}

public DateDome(){

}

//年大于等于0

public boolean isYear(){

boolean suc=false;

if(year0)return suc;

else if(year=0)suc=true;

return suc;

}

//判断月数1-12月

public boolean isMonth(){

boolean suc=false;

if(month0||month12)return false;

else suc=true;

return suc;

}

//判断天数1-31号

public boolean isDay(){

boolean suc=false;

if(day=0||day31)return suc;

else suc=true;

return suc;

}

//是否为闰年

public boolean isRunNian(int year){

boolean suc=false;

if(year=0){

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

suc=true;

}

}

return suc;

}

//判断合法年月日

public boolean isInvaildate(int year,int month, int day){

boolean suc=false;

if(isYear()isMonth()isDay()){

switch(month){

case 1:

suc=true;

break;

case 2:

if(isRunNian(year)day=29){

suc=true;

}else if(day=28){

suc=true;

}

break;

case 3:

suc=true;

break;

case 4:

if(day=30)suc=true;

break;

case 5:

suc=true;

break;

case 6:

if(day=30)suc=true;

break;

case 7:

suc=true;

break;

case 8:

suc=true;

break;

case 9:

if(day=30)suc=true;

break;

case 10:

suc=true;

break;

case 11:

if(day=30)suc=true;

break;

case 12:

suc=true;

break;

}

}

return suc;

}

//根据日期得到天数

public int getDaysByDate(int year,int month,int day){

int days=0;

if(isInvaildate(year,month,day)){

for(int i=0;iyear;i++){

if(isRunNian(i)){

days+=366;

}else{

days+=365;

}

}

for(int i=1;imonth;i++){

if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){

days+=31;

}else if(i==4||i==6||i==9||i==11){

days+=30;

}else if(i==2){

if(isRunNian(year)){

days+=29;

}else{

days+=28;

}

}

}

days+=day-1;

return days;

}else{

System.out.println("处理有非法日期!!!");

return -1;

}

}

//根据天数得到日期数int[]由,年、月、日组成的数组

public int[] getDateByDays(int days){

int das=0;//预计的天数

int y=0,m=1,d=1;//0年1月1号

int[] date=new int[3];

boolean suc=true;

int temp=0;

if(days0){

System.out.println("请输入合法天数!!!");

return new int[]{0,0,0};

}

while(suc){

if(isRunNian(y)){

temp=366;

}else{

temp=365;

}

das+=temp;

if(dasdays){

y++;

}else{

das-=temp;

break;

}

}

while(suc){

if(m==1||m==3||m==5||m==7||m==8||m==10||m==12){

temp=31;

}else if(m==4||m==6||m==9||m==11){

temp=30;

}else if(m==2){

if(isRunNian(y)){

temp=29;

}else{

temp=28;

}

}

das+=temp;

if(dasdays){

m++;

}else{

das-=temp;

break;

}

}

d=days-das+1;

date[0]=y;

date[1]=m;

date[2]=d;

return date;

}

//得到多少天前或后合法日期

public int[] addORsubDay(int dd){

int days=getDaysByDate(year,month,day);

if(days=0){

days+=dd;

if(days0){

return getDateByDays(days);

}else{

System.out.println("处理日期不能小于0年1月1号");

return new int[]{0,0,0};//代表无效日期

}

}else{

System.out.println("处理日期不能小于0年1月1号");

return new int[]{0,0,0};//年,月,日

}

}

//得到两个日期相距天数

public int TwoDate(int[] date1,int[] date2){

int d=-1;

if(isInvaildate(date1[0],date1[1],date1[2])isInvaildate(date2[0],date2[1],date2[2])){

int days1=getDaysByDate(date1[0],date1[1],date1[2]);

int days2=getDaysByDate(date2[0],date2[1],date2[2]);

d=days1-days2;

return d=0?d:-d;

}else

{

System.out.println("处理有非法日期!!!");

return d;

}

}

}

我写了你提出的功能,你还可以扩展其它功能。

求一Java程序代码!!

public class Matriculate {

private int score=400;

public int isMatriculate(Student stu){

if (stu.getIntgretResult()=score||(stu.getIntgretResult()=300stu.getSports()=90)) {

return 1;

}else {

return 0;

}

}

public static void main(String[] args) throws Exception {

Student stu1=new Student("zhangsan",1);

stu1.setIntgretResult(400);

Student stu2=new Student("lisi",2);

stu2.setSports(85);

stu2.setIntgretResult(356);

Matriculate m=new Matriculate();

int c1=m.isMatriculate(stu1);

if (c10) {

System.out.println("id:"+stu1.getId()+"\tname:"+stu1.getName()

+"\tIntgretResult:"+stu1.getIntgretResult()+"\tsports"+stu1.getSports());

System.out.println("被录取");

}

int c2=m.isMatriculate(stu2);

if (c20) {

System.out.println("id:"+stu2.getId()+"\tname:"+stu2.getName()

+"\tIntgretResult:"+stu2.getIntgretResult()+"\tsports"+stu2.getSports());

System.out.println("被录取");

}

}

}

class School{

public School(){}

public School(String schoolname, double scoreLine) {

this.schoolname = schoolname;

this.scoreLine = scoreLine;

}

private String schoolname;

private double scoreLine;

public String getSchoolname() {

return schoolname;

}

public double getScoreLine() {

return scoreLine;

}

}

class Student{

public Student(){}

public Student(String name, int id) {

this.name = name;

this.id = id;

}

private String name;

private int id;

private double intgretResult;

private int sports;

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public int getId() {

return id;

}

public void setId(int id) {

this.id = id;

}

public double getIntgretResult() {

return intgretResult;

}

public void setIntgretResult(double intgretResult) {

this.intgretResult = intgretResult;

}

public int getSports() {

return sports;

}

public void setSports(int sports) {

this.sports = sports;

}

}

急求这个十分简单的JAVA小代码详细注释!!

几年没有碰swing了,给你详细注释了。仔细看。希望对你有所帮助。

import java.awt.*;//java抽象窗口工具包

import java.awt.event.*;//java抽象窗口工具包组件所激发的各类事件的接口和类

public class Test5{//类名

Frame f;//定义一个Frame窗体

TextArea center;//文本域

Label la1,la2,la3;//三个标签

Panel east,south,north;//三块面板

Button b1,b2,b3,b4;//四个按钮

Choice l1;//下拉单选框

TextField t1;//文本域

// textfield只有一行可写

// textarea是一个区域,可以有很多行

public static void main(String[] args){//主函数,程序入口

Test mb = new Test();

mb.go();//调用go方法,初始化界面

}

private void go(){

f = new Frame("留言版程序");//标题

f.addWindowListener(new WindowAdapter(){

public void windowClosing(WindowEvent evt){

f.setVisible(false);

System.exit(0);

//System.exit(0) 0--正常结束程序 1--异常关闭程序

}

});

f.setBounds(0,0,600,400);//布局大小

f.setLayout(new BorderLayout());//显示方式

f.setResizable(false);

//下面都将控件按钮初始化,你懂得

north = new Panel();

south = new Panel();

east = new Panel();

center = new TextArea("留言内容:");

center.setEditable(false);

b1 = new Button("清屏");

b2 = new Button("至顶");

b3 = new Button("至尾");

la1 = new Label("留言版");

la2 = new Label("你");

la3 = new Label(" 地说:");

t1 = new TextField(20);

b4 = new Button("提交");

l1 =new Choice();

l1.add("微笑 ");

l1.add("生气 ");

l1.add("伤心 ");

f.add(BorderLayout.NORTH,north);//布局

f.add(BorderLayout.SOUTH,south);//布局

f.add(BorderLayout.EAST,east);//布局

f.add(BorderLayout.CENTER,center);//布局

north.add(BorderLayout.CENTER,la1);

south.add(la2);//把东西加到面板上

south.add(l1);

south.add(la3);

south.add(t1);//把东西加到面板上

south.add(b4);

east.setLayout(new GridLayout(9,0,1,10));

east.add(b1);

east.add(b2);

east.add(b3);

f.setVisible(true);//可视化

b4.addActionListener(new ActionListener(){//点击提交按钮产生事件

public void actionPerformed(ActionEvent e){

String text1,text2;

text1 = l1.getSelectedItem();

text2 = t1.getText();

t1.setText(null);

if(t1.getText() != ""){//将下拉单选框的内容和你输入在文本框的内容显示在中间面板上

center.append("\n");

center.append(text1);

center.append(text2);

}

}

});

b1.addActionListener(new ActionListener(){//清屏按钮事件,只留下中间面板显示:“留言内容:”,其余清楚

public void actionPerformed(ActionEvent e){

center.setText("留言内容:");

}

});

b2.addActionListener(new ActionListener(){//至顶按钮事件,光标焦点至顶

public void actionPerformed(ActionEvent e){

center.requestFocusInWindow();

center.setCaretPosition(8);

}

});

b3.addActionListener(new ActionListener(){//至尾按钮事件,光标焦点至尾

public void actionPerformed(ActionEvent e){

center.requestFocusInWindow();

center.setCaretPosition(center.getText().length());

}

});

}

}


网站名称:租房java代码,程序员租房代码
转载注明:http://cdweb.net/article/hddgde.html