日期:2014-05-20  浏览次数:20790 次

java程序的一个简单错误
[code=Java][/code]import java.io.*;
public class Management
{
  public static void main(String args[])
  {
  String age1=" ";
  String hour1=" ";
  String salary1=" ";
  String xiaoshou1=" ";
  String xiaoshouzong1=" ";
  String ticheng1=" ";
  try{
  Employee emp1=new Employee();
  System.out.println("Please input the name,age and salary of the manager:");
  BufferedReader get=new BufferedReader(new InputStreamReader(System.in));
  emp1.name=get.readLine();
  age1=get.readLine();
  emp1.age=Integer.parseInt(age1);
  salary1=get.readLine();
  emp1.salary=Double.parseDouble(salary1);
  System.out.println(emp1.printinfo());


  Employee emp2=new Technician();
  System.out.println("Please input the name,age,hour and salary of the Technician:");
  emp2.name=get.readLine();
  age1=get.readLine();
  emp2.age=Integer.parseInt(age1);
  hour1=get.readLine();
  emp2.hour=Double.parseDouble(hour1);
  salary1=get.readLine();
  emp2.salary=Double.parseDouble(salary1);
  System.out.println(emp2.printinfo());


  Employee emp3=new Salesman();
  System.out.println("Please input the name,age,xiaoshou and salary of the Salesman:");
  emp3.name=get.readLine();
  age1=get.readLine();
  emp3.age=Integer.parseInt(age1);
  xiaoshou1=get.readLine();
  emp3.xiaoshou=Double.parseDouble(xiaoshou1);
  salary1=get.readLine();
  emp3.salary=Double.parseDouble(salary1);
  System.out.println(emp3.printinfo());


  Employee emp4=new Salesmanager();
  System.out.println("Please input the name,age,salary,xiaoshouzong and ticheng of the Salesmanager:");
  emp4.name=get.readLine();
  age1=get.readLine();
  emp4.age=Integer.parseInt(age1);
  salary1=get.readLine();
  emp4.salary=Double.parseDouble(salary1);
  xiaoshouzong1=get.readLine();
  emp4.xiaoshouzong=Double.parseDouble(xiaoshouzong1);
  ticheng1=get.readLine();
  emp4.ticheng=Double.parseDouble(ticheng1);
  System.out.println(emp4.printinfo());
  }catch(IOException e){}
  }
}

class Employee
{
  String name;
  int age;
  double salary;
  Employee() {}
  Employee(String name,int age,double salary)
  {
  this.name=name;
  this.age=age;
  this.salary=salary; 
  }
  String printinfo()
  {
  return "经理姓名: "+name+" 年龄:"+age+" 薪水:"+salary;
  }
}

class Manager extends Employee
{
}

class Technician extends Employee
{
  double hour;
  Technician() {}
  Technician(String name,int age,double hour)
  {
  this.name=name;
  this.age=age;
  this.hour=hour;
  this.salary=hour*100; 
  }
  String printinfo()
  {
  return "技术人员姓名:"+name+" 年龄:"+age+" 月工作时间:"+hour+" 薪水:"+salary;
  }
}

class Salesman extends Employee
{
  double xiaoshou;
  Salesman() {}
  Salesman(String name,int age,double xiaoshou)
  {
  this.name=name;