案例二:商场为员工提供了基本工资、物价津贴及房租津贴。其中,物价津贴为基本工资的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
    }
}
结果如下:

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM