JAVA语言基础

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
*
*
*/
public class LanguageBasics {
public static void invokeMe(){
String greeting = “Bonjour,”;
String myPawPrint = “12345”;
SimpleDateFormat df = new SimpleDateFormat(“MM/dd/yyyy HH:mm”);
System.out.print(greeting+” my pawprint is “+ myPawPrint+” and today’s date is “+df.format(new Date()));
}

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    char c1 = 'A'; 
    char c2 = 65;
    short qualityScore = 70;
    float gravitation = (float) 9.8;
    float weight = 50;
    boolean sunny = true;
    boolean warm = false;

    Calendar a = Calendar.getInstance();
    int hour = a.get(Calendar.HOUR_OF_DAY);   
    int minute = a.get(Calendar.MINUTE);  

    if(c1 != c2){
        System.out.println(c1 +" and "+c2 + " are NOT the same");
    }
    else{
        System.out.println(c1 +" and "+c2 + " are the same.");
    }

    if(qualityScore>=0&&qualityScore<=60){
        System.out.println("The quality is bad.");
    }
    else{
        System.out.println("Good quality.");
    }

    float force = weight * gravitation;
        System.out.println("Force = "+force);



    if(sunny==true&&warm==true){
        System.out.println( "Go hiking.");
    }
    else if(sunny==false&&warm==true){
        System.out.println( "Go barbeque.");
    }
    else{
        System.out.println( "Stay home.");
    }
    //5-10 morning        hour>=5&&hour<=10   "The current time is 08:08 in the MORNING."
    //11-16 afternoon     hour>=11&&hour<=16  "The current time is 08:08 in the AFTERNOON."
    //17-22 evening       hour>=17&&hour<=22  "The current time is 08:08 in the EVENING."
    //23-4 night          hour>=23&&hour<=24&&hour>=0&&hour<=4  "The current time is 08:08 in the NIGHT."
    //0-23 wrong          "You have the wrong time."
    int b =  ((hour>=5&&hour<11)==true?1:0)
            +((hour>=11)==true?1:0)
            +((hour>=11&&hour<17)==true?1:0)
            +((hour>=17)==true?1:0)
            +((hour>=17&&hour<23)==true?1:0)
            +((hour>=23)==true?1:0)
            +((hour>=23&hour<=24)==true?1:0)
            +((hour>=0&hour<=4)==true?5:0);
    switch(b){
    case 1:
        System.out.println("The current time is "+hour + ":" +minute+" in the MORNING.");
        break;
    case 2:
        System.out.println("The current time is "+hour + ":" +minute+" in the AFTERNOON.");
        break;
    case 3:
        System.out.println("The current time is "+hour + ":" +minute+" in the EVENING.");
        break;
    case 4:
        System.out.println("The current time is "+hour + ":" +minute+" in the NIGHT.");
        break;
            case 5:
        System.out.println("The current time is "+hour + ":" +minute+" in the NIGHT.");
        break;
    default:
        System.out.println("You have the wrong time.");
    }



    for (int count = 2; count <= 6; count++) {
    if(count%3==0){
    System.out.println("Count:"+count);
        }
    }

    int countDown = 5;
    while(countDown>=0){
    System.out.println("Count Down:"+countDown);
    countDown = countDown-1;
    }
    System.out.println("“Houston, we have a lift off!”");    

    invokeMe();
    // TODO code application logic here

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值