Java Person Teacher 4
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Implement a class Person.
Implement a class Teacher that extends Person.
class Person { protected String Surname, Name; protected int Age; Person(String Surname, String Name, int Age) // Constructor public String toString() // Print Surname Name Age } class Teacher extends Person { protected String Subject; protected int Salary; Teacher(String Surname, String Name, int Age, String Subject, int Salary) // Constructor public String toString() // Print Surname Name Age Subject Salary } class ListOfPeople { ArrayList<Person> a = new ArrayList<Person>(); public void add(Person p) // Add person p to array list public int size() // Return size of array list public String toString() // Print people in array list. Each person print in a separate line public ListOfPeople getTeachers() // Return the list of Teachers only public int GetNumberOfTeachers() // Return the number of Teachers in the list public ListOfPeople getTeachers(String Subject) // Return the list of Teachers who runs the subject Subject public int GetNumberOfTeachers(String Subject) // Return the number of Teachers who runs the subject Subject }
List of people will be created:
ListOfPeople list = new ListOfPeople();
Input data will be added to the list. The list of Teachers and their number will be printed
System.out.print(list.getTeachers()); System.out.println(list.GetNumberOfTeachers());
The list of People who runs Math will be printed
System.out.print(list.getTeachers("Math"));
The number of Teachers who runs Physics will be printed
System.out.println(list.GetNumberOfTeachers("Physics"));
Input
Each line contains one of two types of people in the next format:
Person Surname Name Age
Teacher Surname Name Age Subject Salary
Output
Print the list of Teachers first. In the next line print the number of Teachers. Then print list of Teachers who runs Math. Then print the number of Teachers who runs Physics.
Examples
Input #1
Answer #1
Submissions 666
Acceptance rate 55%