java简单的异常_java程序的一个简单异常

java程序的一个简单异常

热度:8342   发布时间:2013-02-25 21:43:53

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;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值