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');
}
}

 

posted @ 2020-07-13 19:40  靠谱杨  阅读(123)  评论(0编辑  收藏  举报