zoukankan      html  css  js  c++  java
  • Document

     1 /**
     2  * 需求分析:根据输入的天数是否是周六或是周日,
     3  * 并且天气的温度大于28摄氏度,则外出游泳,否则钓鱼
     4  * @author chenyanlong
     5  * 日期:2017/10/14
     6  */
     7 package com.hp.test03;
     8 
     9 import java.util.Scanner;
    10 
    11 public class HS_JudgeOutgoing {
    12 
    13     public static void main(String[] args) {
    14         // TODO Auto-generated method stub
    15         int day;
    16         double temperature;
    17         //double temperature = 0.0;
    18         
    19         System.out.println("请输入今天星期几,如果周n ,请输入”n“,eg:7");      
    20         Scanner input=new Scanner(System.in);
    21         day=input.nextInt();
    22         
    23         if(day==6||day==7){
    24             //温度判断
    25             System.out.println("请输入今天的温度,eg:29.8");      
    26             Scanner input2=new Scanner(System.in);
    27             temperature=input2.nextDouble();
    28             System.out.println("温度:"+temperature);
    29             if(temperature>25){
    30                 System.out.println("今天适合——游泳");
    31             }else{
    32                 System.out.println("今天适合——钓鱼");
    33             }
    34         }else{
    35             System.out.println("你还是老实写代码!!");
    36         }
    37         
    38         
    39     }
    40 }
     1 /**
     2  * 需求分析:判断成绩是否合格
     3  */
     4 package com.hp.test03;
     5 
     6 import java.util.Scanner;
     7 
     8 public class HS_JudgeScore {
     9 
    10     public static void main(String[] args) {
    11         // TODO Auto-generated method stub
    12          int score;
    13          System.out.println("请输入你的成绩");
    14          
    15          Scanner input=new Scanner(System.in);
    16          score=input.nextInt();
    17          
    18          //判断成绩是否合格
    19          if(score<60){
    20              System.out.println("成绩不及格");
    21          }else if(score<70){
    22              System.out.println("成绩差");
    23          }else if(score<80){
    24              System.out.println("成绩中等");
    25          }
    26          else if(score<90){
    27              System.out.println("成绩良好");
    28          }else{
    29              System.out.println("成绩优秀");
    30          }
    31          
    32     }
    33 
    34 }
    /**
     * 需求说明: 根据分解后的数字之和,判断用户是否中奖
     * @author chenyanlong
     * 时间:2017/10/14
     */
    package com.hp.test03;
    
    import java.util.Scanner;
    
    public class HS_SumGetMp3 {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            //定义用到的所有变量
            int  num,a,b,c,d,sum;
            System.out.println("请输入4位的会员卡号:");
            
            //键盘数据的输入与读取
            Scanner input=new Scanner(System.in);
            num=input.nextInt();
            
            //分离num,抽出千位,百位,十位,个位
            System.out.println("会员卡号是:"+num);
            System.out.println("----------------------------------");
            a=num/1000;//千位
            b=num/100%10;//百位
            c=num/10%10;//十位
            d=num%10;//个位
            System.out.println("千位数:"+a+",百位数:"+b+",十位数:"+c+",个位数:"+d);
            System.out.println("----------------------------------");
           
            //a,b,c,d之和
            sum=a+b+c+d;
            System.out.println("会员卡号"+num+"各个位之和:"+sum);
            
            //判断是否中奖
            if(sum>30){
                System.out.println("会员卡号"+num+"的会员,你中奖了!奖品是剑豪最新版皮肤!!!");
            }else{
                System.out.println("很遗憾,你没有中奖!");
            }
        }
    
    }
     1 /**
     2  * 需求说明: switch的基本使用
     3  * @author chenyanlong
     4  * 时间:2017/10/14
     5  */
     6 package com.hp.test03;
     7 
     8 import java.util.Scanner;
     9 
    10 public class HS_Switch {
    11 
    12     public static void main(String[] args) {
    13         
    14       int score,a;
    15       System.out.println("请输入成绩:");
    16       Scanner input=new Scanner(System.in);
    17       score=input.nextInt();
    18        
    19       a=score/10;
    20        switch(a){
    21           case 10:
    22           case 9:
    23               System.out.println("优秀");
    24               break;
    25           case 8:
    26               System.out.println("良好");
    27               break;
    28           case 7:
    29               System.out.println("中等");
    30               break;
    31           case 6:
    32               System.out.println("差");
    33               break;
    34          default:
    35              System.out.println("不及格");
    36        }
    37      
    38     }
    39 
    40 }
     1 /**
     2  * 需求分析:三目运算符的基本使用
     3  * @author chenyanlong
     4  * 日期:2017/10/14
     5  */
     6 package com.hp.test03;
     7 
     8 public class HS_TernaryOperator {
     9 
    10     public static void main(String[] args) {
    11         // TODO Auto-generated method stub
    12        int min=3<1?2:3;//条件为false,输入3
    13        System.out.println("输出了:"+min);
    14        
    15        int min2=3>1?2:3;//条件为ture,输入2
    16        System.out.println("输出了:"+min2);
    17        
    18     }
    19 
    20 }
  • 相关阅读:
    Apache日志分析
    iptables日志探秘
    php与其他一些相关工具的安装步骤分享
    ERROR 1 (HY000): Can't create/write to file '/tmp/#sql_830_0.MYI' (Errcode: 13)
    一些可能需要的正则
    restful api的简单理解
    认识MySQL Replication
    如何处理缓存失效、缓存穿透、缓存并发等问题
    经典算法mark
    php常用的一些代码
  • 原文地址:https://www.cnblogs.com/chenyanlong/p/7668871.html
Copyright © 2011-2022 走看看