案例二:商场为员工提供了基本工资、物价津贴及房租津贴。其中,物价津贴为基本工资的40%,房租津贴为基本工资的25%。要求:从控制台输入基本工资,并计算输出实领工资。

package project_02;

import java.util.Scanner;

/**快捷键:shift+Alt+j
 * 
 * 2018-9-7 18:44:47
 *@author Sauron XiaMen
 */
public class Salary {
    //输入基本工资3000
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        System.out.print("请输入基本工资:");
        double salary=input.nextDouble();
        double prices=salary*0.4;   //物价津贴
        double rent=salary*0.25;    //房租津贴
        //输出结果
        System.out.println("该员工的工资细目为:");
        System.out.println("基本工资为:"+salary);
        System.out.println("物价津贴为:"+prices);
        System.out.println("房租津贴为:"+rent);
        System.out.println("员工薪水是:"+(salary+prices+rent));
        input.close();  //关闭Scanner
    }
}
结果如下:

 

posted @ 2018-09-07 18:56  Sauron_Three  阅读(2498)  评论(0编辑  收藏  举报