import java. util. Scanner;
interface Calculateable
{
abstract int getGrade ( ) ;
}
abstract class Teacher
{
private int id;
private String name;
private int worknum;
public int getId ( ) {
return id;
}
public void setId ( int id)
{
this . id= id;
}
public String getName ( )
{
return name;
}
public void setName ( String name)
{
this . name= name;
}
public int getWorknum ( )
{
return worknum;
}
public void setWorknum ( int worknum)
{
this . worknum= worknum;
}
abstract int getYearEarn ( ) ;
}
class Lecture extends Teacher implements Calculateable
{
public Lecture ( int id, String name, int worknum)
{
setId ( id) ;
setName ( name) ;
setWorknum ( worknum) ;
}
public int getGrade ( )
{
int x= getWorknum ( ) ;
int grade= 0 ;
if ( x< 300 )
grade= 0 ;
if ( x< 400 && x>= 300 )
grade= 1 ;
if ( x< 600 && x>= 400 )
grade= 2 ;
if ( x>= 600 )
grade= 3 ;
return grade;
}
public int getYearEarn ( )
{
int bonus = 0 ;
int worknum= getWorknum ( ) ;
int x= getGrade ( ) ;
if ( x== 0 )
bonus= - 1000 ;
else if ( x== 1 )
bonus= ( worknum- 300 ) * 50 ;
else if ( x== 2 )
bonus= ( worknum- 300 ) * 70 ;
else if ( x== 3 )
bonus= ( worknum- 300 ) * 90 ;
return bonus;
}
}
class Professor extends Teacher implements Calculateable
{
public Professor ( int id, String name, int worknum)
{
setId ( id) ;
setName ( name) ;
setWorknum ( worknum) ;
}
public int getGrade ( )
{
int x= getWorknum ( ) ;
int grade = 0 ;
if ( x< 400 )
grade= 0 ;
if ( x< 500 && x>= 400 )
grade= 1 ;
if ( x< 800 && x>= 500 )
grade= 2 ;
if ( x>= 800 )
grade= 3 ;
return grade;
}
public int getYearEarn ( )
{
int bonus = 0 ;
int worknum= getWorknum ( ) ;
int x= getGrade ( ) ;
if ( x== 0 )
bonus= - 2000 ;
else if ( x== 1 )
bonus= ( worknum- 400 ) * 70 ;
else if ( x== 2 )
bonus= ( worknum- 400 ) * 90 ;
else if ( x== 3 )
bonus= ( worknum- 400 ) * 100 ;
return bonus;
}
}
class IO
{
static int getId ( )
{
Scanner sc= new Scanner ( System. in) ;
System. out. println ( "请输入教师工号:" ) ;
return sc. nextInt ( ) ;
}
static String getName ( )
{
Scanner sc= new Scanner ( System. in) ;
System. out. println ( "请输入教师姓名:" ) ;
return sc. nextLine ( ) ;
}
static int getWorknum ( )
{
Scanner sc= new Scanner ( System. in) ;
System. out. println ( "请输入教师工作量:" ) ;
return sc. nextInt ( ) ;
}
static void print ( Teacher x)
{
System. out. println ( "工号为" + x. getId ( ) + "的老师" + x. getName ( ) + "的" + "年终奖金为:" + x. getYearEarn ( ) ) ;
}
}
public class Test5_4_zxj
{
public static void main ( String[ ] args)
{
Lecture x1= new Lecture ( IO. getId ( ) , IO. getName ( ) , IO. getWorknum ( ) ) ;
Professor x2= new Professor ( IO. getId ( ) , IO. getName ( ) , IO. getWorknum ( ) ) ;
IO. print ( x1) ;
IO. print ( x2) ;
}
}