2018.12.21 任务

作业链接:https://pan.baidu.com/s/1jzGwHeAgw27zxibwAZDCqQ

提取码:fr9r 

一、笔记

1在java中,标识符用来为程序中的常量、变量、方法、类、接口和包命名。

驼峰命名法:一个单词由多个单词连接在一起,第一个单词小写开始,第一个单词和之后的每一个单词首字母都大写。

2.变量使用可以分为两步:声明变量赋值([访问修饰符]数据类型 变量名=数值)和使用。

变量命名不能使用关键字,不能以数字开头 中间不能有空格 不能全数字。首字母要小写。

在输出语句中,变量和字符串之间要用+相连。

 

3.常量定义:final double PI=3.14;都要大写。不同字符串可以用用下划线相连。

4实现键盘上输入数据:

Scanner sc =new Scanner(System.in);

r=sc.nextInt();//控制台接收的数据赋值给变量r:。

 

5.8种数据类型分别为:byle(取值范围-2的7次方到2的7次方-1)、short(-2的15次方到2的15次方-1)、int(-2的31次方到2的31次方-1)、long(-2的63次方到2的63次方-1)

float、double、char、boolean.

6.数据类型转换分为自动类型转换(将低级别的类型赋值给高级别类型)和强制类型转换(将高赋值给低)。

 

7.运算符

赋值运算符

算术运算符

对于++:

++在前面立即执行。++在后面过后在执行

 一、作业

1.

package com.homework;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        int basewage;
        double prices;
        double rent;
        double wage;
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入基本工资:");
        basewage=sc.nextInt();
        prices=basewage*0.4;
        rent=basewage*0.25;
        wage=basewage+prices+rent;
        System.out.println("该员工的工资细目为:"+"\n基本工资为:"+basewage
                +"\n物价津贴为:"+prices+"\n房租津贴为:"+rent+"\n员工薪水是"+wage);
    }
}

2.

package com.homework;

import java.util.Scanner;

public class Sum {
    public static void main(String[] args) {
        int num,sum;
        System.out.println("请输入一个五位数:");
        Scanner sc=new Scanner(System.in);
        num=sc.nextInt();
        int gewei=num%10;
        int shiwei=num/10%10;
        int baiwei=num/100%10;
        int qianwei=num/1000%10;
        int wanwei=num/10000;
        sum=gewei+shiwei+baiwei+qianwei+wanwei;
        System.out.print("万位数:"+wanwei+"\t千位数:"+qianwei+"\t百位数:"+baiwei+"\t十位数:"+shiwei+"\t个位数:"+gewei+"\n各个位数之和:"+sum);
    }
}

 

posted @ 2018-12-21 20:21  毕家唆  阅读(85)  评论(0编辑  收藏  举报