zoukankan      html  css  js  c++  java
  • 12-21变量、常量

    1.输入五位数,输出各位数与和

    package com.qiuhe;
    
    import java.util.Scanner;
    
    public class Qiuhe {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入五位数: ");
            int x = sc.nextInt();
            System.out.println("万位:"+x/10000);
            System.out.println("千位:"+x/1000%10);
            System.out.println("百位:"+x/100%10);
            System.out.println("十位:"+x/10%10);
            System.out.println("个位:"+x/1%10);
            System.out.print("这五位数相加之和是:");
            System.out.println(x/10000+x/1000%10+x/100%10+x/10%10+x/1%10);
                    
        }
    }

    2.商场

    package com.gz;
    
    import java.util.Scanner;
    
    public class Gzi {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入基本工资:");
            int x = sc.nextInt();
            System.out.println("该员工的工资细目位:");
            System.out.println("基本工资位:"+x);
            double jt = x*40/100;
            System.out.println("物价津贴为:"+jt);
            double fz = x*25/100;
            System.out.println("房租津贴为:"+fz);
            System.out.print("员工薪水是:");
            System.out.print(x+jt+fz);    
        }
    }

    3.笔记

    String //字符串
    char //字符
    int //整形
    double //非证型

    Java中基本数据类型取值范围

    byte 8bit -2的7次方---2的7次方-1

    short 16bit -2的15次方---2的15次方-1

    int 32bit -2的31次方---2的31次方-1

    long 64bit -2的63次方---2的63次方-1


    变量首字母小写
    final常量全部大写
    ctrl+shift+o 自动倒入包

    ++a加加在前表明立刻执行
    a++加加在后表示过后执行

    int a = 1;
    int b = a++ + ++a + ++a + a++ + a++ + ++a + ++a
    1 3 4 4 5 7 8

    百度网盘:https://pan.baidu.com/disk/home?#/all?vmode=list&path=%2F%E4%BD%9C%E4%B8%9A

  • 相关阅读:
    python函数
    python文件IO操作
    LAMP项目上线
    linux下的小工具
    linux下自有服务
    Lesson_Swift2
    枚举
    使用文件流下载附件
    Global中的Timer计时器
    IE11下的NPOI导出提示__doPostBack未定义解决方案
  • 原文地址:https://www.cnblogs.com/zxbaoer/p/10158921.html
Copyright © 2011-2022 走看看