Java输入输出
/**
*
*/
/**
* @author 86152
*
*/
package Employee;
import java.util.Scanner;
public class Employee{
private int ID; //工作编号
private String name; //姓名
private int salary; //薪 水
private double upRate; //薪水增长率
Employee(int ID,String name,int salary,double upRate)
{
this.ID=ID;
this.name=name;
this.salary=salary;
this.upRate=upRate;
}
Employee()
{
System.out.println("请输入员工姓名:");
Scanner sc=new Scanner(System.in);
name=sc.next();
System.out.println("请输入员工工作ID:");
ID=sc.nextInt();
System.out.println("请输入员工月薪:");
salary=sc.nextInt();
System.out.println("请输入员工薪水增长率:");
upRate=sc.nextDouble();
sc.close();
}
public int getID() {
return ID;
}
public int getsalary()
{
return salary;
}
public String getName()
{
return name;
}
public double getUpRate()
{
return upRate;
}
public void figureFinal() //计算薪水增长额,总薪水并且输出、
{
int months;
System.out.println("请输入计算几个月:");
Scanner IN=new Scanner(System.in);
months=IN.nextInt();
double sum=0; //总薪水;
double T=salary;
double tempSalary; //增长量
for(int i=1;i<=months;i++)
{
T=T*(1+upRate);
sum=sum+T;
}
tempSalary=sum-salary*months;
System.out.println(months+"个月之后的薪水总额为:"+sum+"净增加额为:"+tempSalary);
IN.close();
}
public static void main(String[] args)
{
Employee em1=new Employee(1001,"name1",5000,0.03);
Employee em2=new Employee();
em2.figureFinal();
System.out.println("下面给出员工的个人信息:");
System.out.print("姓名:"+em1.getName()+" "+"工作编号:"+em1.getID()+" "+"月薪:"+em1.getsalary()+" "+"薪水增长率:"+em1.getUpRate()+'\n');
System.out.println("姓名:"+em2.getName()+" "+"工作编号:"+em2.getID()+" "+"月薪:"+em2.getsalary()+" "+"薪水增长率:"+em2.getUpRate()+'\n');
}
}
好看请赞,养成习惯:) 本文来自博客园,作者:靠谱杨, 转载请注明原文链接:https://www.cnblogs.com/rainbow-1/p/13295231.html
欢迎来我的51CTO博客主页踩一踩 我的51CTO博客
文章中的公众号名称可能有误,请统一搜索:靠谱杨的秘密基地