import java.util.Calendar;
我們注重客戶提出的每個要求,我們充分考慮每一個細節(jié),我們積極的做好成都做網站、成都網站設計服務,我們努力開拓更好的視野,通過不懈的努力,創(chuàng)新互聯建站贏得了業(yè)內的良好聲譽,這一切,也不斷的激勵著我們更好的服務客戶。 主要業(yè)務:網站建設,網站制作,網站設計,小程序開發(fā),網站開發(fā),技術開發(fā)實力,DIV+CSS,PHP及ASP,ASP.Net,SQL數據庫的技術開發(fā)工程師。
//這是問題(1)的函數
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());
//結果是: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);
//結果是366
寫了一個代碼,代碼如下,可以進行參考
public?class?sum?{
public?static?void?main(String[]?args)?{
//創(chuàng)建一個Scanner的對象input
Scanner?input?=?new?Scanner(System.in);?
//提示用戶輸入數據?
System.out.print("請輸入一個整數");
//將輸入的值賦給n
int?n?=?input.nextInt();
//定義變量接收計算后的和
int?sum?=?0;
//利用循環(huán)進行求和
for?(int?i?=?0;?i?=?n;?i++)?{
sum+=i;
}
//輸出最后的和
System.out.println("從0一直到"+n+"的所有整數的和是:"+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轉換為char類型,執(zhí)行people.printLetter()方法,如果出現異常則捕獲,并輸出異常的錯誤信息!
people.printLetter((char) i);
}
for (int i = 0; i 128; i++) {
// 【代碼6】 //將i轉換為char類型,執(zhí)行people. printDigit
// ()方法,如果出現異常則捕獲,并輸出異常的錯誤信息!
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("請輸入價格:");
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("啟動普通打印機");
}
public void print(){
System.out.println("普通打印機打印");
}
}
class LaserPrinter extends Printer{
public void print(){
System.out.println("激光打印機打印");
}
public void close(){
System.out.println("激光打印機關閉");
}
}
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();
}
}
網站名稱:激光刻字編程java代碼,激光刻字編程java代碼大全
URL地址:http://jinyejixie.com/article0/dssdpio.html
成都網站建設公司_創(chuàng)新互聯,為您提供微信公眾號、響應式網站、網站導航、網站排名、網站設計公司、網站建設
聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯