zoukankan      html  css  js  c++  java
  • 作业

    public class Demo1 {
         public static void main(String[] args) {
             int age = 25;
             String name = "小明";
             int workTime = 3;
             String way = "Java";
             String favorite = "篮球";
             String projectCount = "5";
            
             System.out.print("这个同学的姓名是:" + name + " ");
             System.out.print("这个同学的年龄是:" + age + " ");  
             System.out.print("工作了" + workTime + "年了" + " ");
             System.out.print("做过" + projectCount + "个项目" + " ");
             System.out.print("技术方向是" + way + " ");
             System.out.print("兴趣爱好是" + favorite);
            
         }
    }

    package com.day03;

    import java.util.Scanner;

    public class Demo3 {
       public static void main(String[] args) {
           int cusNo; //客户的会员卡号
           //输入会员卡号
           System.out.print("请输入4位会员卡号:");
           Scanner input = new Scanner(System.in);
           cusNo = input.nextInt();
           System.out.println("会员卡号是:" + cusNo);
       }
    }

    package com.day03;
    import java.util.*;
    public class Demo4 {
             public static void main(String[] args) {
        int custNo;
        System.out.println("请输入四位卡号");
        Scanner input = new Scanner(System.in);
        custNo = input.nextInt();
        System.out.print("会员卡号是:" + custNo);
        //利用“/”和“%” 运算符获取每位的数字
        int gewei = custNo %10;
        int shiwei = custNo / 10 % 10;
        int baiwei = custNo / 100 % 10;
        int qianwei = custNo / 1000;
        System.out.print("千位数:" + qianwei + ",百位数: " + baiwei +
                ",十位数:" + shiwei + ",个位数:" + gewei);
        //利用“+”运算符计算各位数字之和
        int sum = gewei + shiwei + baiwei + qianwei;
        System.out.print("会员卡号" + custNo + "各位之和:" + sum);
             }
    }

    package com.day03;
    import java.util.*;
    public class Demo2 {
        public static void main(String[] arges){
            int cusNo;
            //输入会员卡号
            System.out.println("请输入4位会员卡号:");
            Scanner input=new Scanner(System.in);   //System.in 代表键盘
            cusNo=input.nextInt();
            System.out.println("会员卡号是:"+ cusNo);
            //利用 "/" 和"%" 运算符获得每位数字
            int gewei=cusNo % 10;
            int shiwei=cusNo / 10 % 10;
            int baiwei=cusNo / 100 % 10;
            int qianwei=cusNo / 1000 % 10;
            System.out.println("千位数:"+qianwei+", 百位数:"+baiwei+" ,十位数:"+shiwei+" ,个位数:"+gewei);
            //利用 “+” 运算符计算数字之和
            int sum=gewei+shiwei+baiwei+qianwei;
            System.out.println("会员卡号"+cusNo+"各位之和:"+sum);
            //判断是否中奖
            if(sum > 20){
                System.out.println("会员卡号"+cusNo+"的会员,您中奖了!奖品是MP3!");
            }else{
                System.out.println("会员卡号"+cusNo+"的会员,很遗憾您没有中奖");
            }
        }
    }

    package com.day03;
    import java.text.DecimalFormat;
    public class Demo6 {
         public static void main(String[] args) {

    //       创建DecimalFormat对象
             DecimalFormat df = new DecimalFormat("#.00");
             System.out.println(df.format(0.123));
             System.out.println(df.format(1.123));
             System.out.println(df.format(24.15));
             System.out.println(df.format(10.59));
       }
    }

  • 相关阅读:
    Treap 树堆 容易实现的平衡树
    (转)Maven实战(二)构建简单Maven项目
    (转)Maven实战(一)安装与配置
    根据请求头跳转判断Android&iOS
    (转)苹果消息推送服务器 php 证书生成
    (转)How to renew your Apple Push Notification Push SSL Certificate
    (转)How to build an Apple Push Notification provider server (tutorial)
    (转)pem, cer, p12 and the pains of iOS Push Notifications encryption
    (转)Apple Push Notification Services in iOS 6 Tutorial: Part 2/2
    (转)Apple Push Notification Services in iOS 6 Tutorial: Part 1/2
  • 原文地址:https://www.cnblogs.com/zhangbupang/p/11081467.html
Copyright © 2011-2022 走看看