import java.util.Calendar;
我們注重客戶提出的每個(gè)要求,我們充分考慮每一個(gè)細(xì)節(jié),我們積極的做好成都做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)服務(wù),我們努力開拓更好的視野,通過不懈的努力,創(chuàng)新互聯(lián)建站贏得了業(yè)內(nèi)的良好聲譽(yù),這一切,也不斷的激勵(lì)著我們更好的服務(wù)客戶。 主要業(yè)務(wù):網(wǎng)站建設(shè),網(wǎng)站制作,網(wǎng)站設(shè)計(jì),小程序開發(fā),網(wǎng)站開發(fā),技術(shù)開發(fā)實(shí)力,DIV+CSS,PHP及ASP,ASP.Net,SQL數(shù)據(jù)庫的技術(shù)開發(fā)工程師。
//這是問題(1)的函數(shù)
public static Boolean isLegal(int year,int month,int day){
boolean run=false;
if(month1||month12||day1||day31) return false;
if((year%4==0)(year%100!=0)||(year%400==0)) //是否是閏年
run=true;
switch(month){
case 2:
if(run){
if(day29) return false;
}
else{
if(day28) return false;
}
break;
case 4:
case 6:
case 9:
case 11:if(day30) return false;
}
return true;
}
//這是第(2)問的代碼
Calendar cld = Calendar.getInstance();
cld.set(2009, 0,18);//月份是從0開始的
cld.set(Calendar.DAY_OF_YEAR, cld.get(Calendar.DAY_OF_YEAR)+365);
System.out.println(cld.getTime());
//結(jié)果是:Mon Jan 18 13:50:40 CST 2010
//下面是第三問的代碼
Calendar cld1 = Calendar.getInstance();
cld1.set(2009, 0,18);//月份是從0開始的
Calendar cld2 = Calendar.getInstance();
cld2.set(2008, 0,18);
long d=cld1.getTimeInMillis()-cld2.getTimeInMillis();
d=d/1000/60/60/24;
System.out.println(d);
//結(jié)果是366
寫了一個(gè)代碼,代碼如下,可以進(jìn)行參考
public?class?sum?{
public?static?void?main(String[]?args)?{
//創(chuàng)建一個(gè)Scanner的對(duì)象input
Scanner?input?=?new?Scanner(System.in);?
//提示用戶輸入數(shù)據(jù)?
System.out.print("請輸入一個(gè)整數(shù)");
//將輸入的值賦給n
int?n?=?input.nextInt();
//定義變量接收計(jì)算后的和
int?sum?=?0;
//利用循環(huán)進(jìn)行求和
for?(int?i?=?0;?i?=?n;?i++)?{
sum+=i;
}
//輸出最后的和
System.out.println("從0一直到"+n+"的所有整數(shù)的和是:"+sum);
}
}
class NoLowerLetterException extends Exception {
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轉(zhuǎn)換為char類型,執(zhí)行people.printLetter()方法,如果出現(xiàn)異常則捕獲,并輸出異常的錯(cuò)誤信息!
people.printLetter((char) i);
}
for (int i = 0; i 128; i++) {
// 【代碼6】 //將i轉(zhuǎn)換為char類型,執(zhí)行people. printDigit
// ()方法,如果出現(xiàn)異常則捕獲,并輸出異常的錯(cuò)誤信息!
people.printDigit((char) i);
}
}
}
Media類:
import java.util.Scanner;
/**
* @author Administrator
*
*/
public class Media {
private String name;
private String author;
private String publish;
private double price;
/**
* @throws Exception
*/
public Media() throws Exception
{
@SuppressWarnings("resource")
Scanner scanner = new Scanner(System.in);
System.out.println("請輸入名稱:");
setName(scanner.nextLine());
System.out.println("請輸入作者:");
setAuthor(scanner.nextLine());
System.out.println("請輸入出版社:");
setPublish(scanner.nextLine());
System.out.println("請輸入價(jià)格:");
setPrice(scanner.nextDouble());
scanner.close();
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the author
*/
public String getAuthor() {
return author;
}
/**
* @param author the author to set
*/
public void setAuthor(String author) {
this.author = author;
}
/**
* @return the publish
*/
public String getPublish() {
return publish;
}
/**
* @param publish the publish to set
*/
public void setPublish(String publish) {
this.publish = publish;
}
/**
* @return the price
*/
public double getPrice() {
return price;
}
/**
* @param price the price to set
*/
public void setPrice(double price) {
this.price = price;
}
}
public class Book extends Media {
/**
* @throws Exception
*
*/
public Book() throws Exception{
super();
System.out.println("I am a book!");
}
}
public class Cd extends Media {
/**
*
* @throws Exception
*/
public Cd() throws Exception{
super();
System.out.println("I am a cd!");
}
}
class Printer {
public String type;
public String manner;
public Printer(){};
public Printer(String type,String manner){
this.type=type;
this.manner=manner;
}
public void startup(){
System.out.println("啟動(dòng)普通打印機(jī)");
}
public void print(){
System.out.println("普通打印機(jī)打印");
}
}
class LaserPrinter extends Printer{
public void print(){
System.out.println("激光打印機(jī)打印");
}
public void close(){
System.out.println("激光打印機(jī)關(guān)閉");
}
}
public class Test{
public static void main(String[] args){
Printer p1=new Printer();
Printer p2=new Printer("123","方式1");
p1.startup();
p1.print();
LaserPrinter j1= new LaserPrinter();
j1.startup();
j1.print();
j1.close();
}
}
網(wǎng)站名稱:激光刻字編程java代碼,激光刻字編程java代碼大全
URL地址:http://www.rwnh.cn/article0/dssdpio.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號(hào)、響應(yīng)式網(wǎng)站、網(wǎng)站導(dǎo)航、網(wǎng)站排名、網(wǎng)站設(shè)計(jì)公司、網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)