You are given 3 lines of input. In the first two lines you have to scan space separated details of the first and the second person respectively in the order: name, admission number, class, percentage, pass result, route number and blood group. Now you will be given an admission number, and you have to return the name, percentage and route of that person in a single line (space-separated). If the admission number is not present, return the error message 'No entry found'. Note that you have to make three classes, a student class(containing name, admission number, and class) and a report class that inherits the student class (and has the percentage and pass result) and a bus class that inherits the student class (and has the route number and blood group). Make appropriate methods where needed and in the driver class, make appropriate calls to these methods for the required output.Sample test case:Input:A 1 9 99 yes 27 B+B 2 10 88 no 28 A+2Output:B 88 28 Explanation: The person whose admission number is 2 has the name B, percentage 88 and route number 28.
Question
You are given 3 lines of input. In the first two lines you have to scan space separated details of the first and the second person respectively in the order: name, admission number, class, percentage, pass result, route number and blood group. Now you will be given an admission number, and you have to return the name, percentage and route of that person in a single line (space-separated). If the admission number is not present, return the error message 'No entry found'. Note that you have to make three classes, a student class(containing name, admission number, and class) and a report class that inherits the student class (and has the percentage and pass result) and a bus class that inherits the student class (and has the route number and blood group). Make appropriate methods where needed and in the driver class, make appropriate calls to these methods for the required output.Sample test case:Input:A 1 9 99 yes 27 B+B 2 10 88 no 28 A+2Output:B 88 28 Explanation: The person whose admission number is 2 has the name B, percentage 88 and route number 28.
Solution 1
This problem can be solved using Object Oriented Programming in Python. Here is a step by step solution:
Step 1: Define the Student class with attributes name, admission number, and class.
class Student:
def __init__(self, name, admission_number, class_name):
self.name = name
self.admission_number = admission_number
self.class_name = class_name
Step 2: Define the Report class that inherits from the Student class. It has additional attributes percentage and pass result.
class Report(Student):
def __init__(self, name, admission_number, class_name, percentage, pass_result):
super().__init__(name, admission_number, class_name)
self.percentage = percentage
self.pass_result = pass_result
Step 3: Define the Bus class that inherits from the Student class. It has additional attributes route number and blood group.
class Bus(Student):
def __init__(self, name, admission_number, class_name, route_number, blood_group):
super().__init__(name, admission_number, class_name)
self.route_number = route_number
self.blood_group = blood_group
Step 4: In the main function, create objects of the Report and Bus classes using the input data. Store these objects in a dictionary with the admission number as the key.
def main():
students = {}
for _ in range(2):
name, admission_number, class_name, percentage, pass_result, route_number, blood_group = input().split()
students[admission_number] = (Report(name, admission_number, class_name, percentage, pass_result), Bus(name, admission_number, class_name, route_number, blood_group))
Step 5: Take the admission number as input
Solution 2
Sure, here is a Python solution for the problem:
class Student:
def __init__(self, name, admission_number, class_number):
self.name = name
self.admission_number = admission_number
self.class_number = class_number
class Report(Student):
def __init__(self, name, admission_number, class_number, percentage, pass_result):
super().__init__(name, admission_number, class_number)
self.percentage = percentage
self.pass_result = pass_result
class Bus(Student):
def __init__(self, name, admission_number, class_number, route_number, blood_group):
super().__init__(name, admission_number, class_number)
self.route_number = route_number
self.blood_group = blood_group
def find_student(admission_number, students):
for student in students:
if student.admission_number == admission_number:
return student
return None
# Input
students = []
students.append(Bus('A', 1, 9, 27, 'B+'))
students.append(Bus('B', 2, 10, 28, 'A+'))
admission_number = 2
# Find student
student = find_student(admission_number, students)
# Output
if student is not None:
print(student.name, student.route_number)
else:
print('No entry found')
This script first defines the classes Student, Report, and Bus as described in the problem statement. It then creates a list of Bus objects, each representing a student. The find_student function is used to find a student by their admission number. Finally, the script prints the name and route number of
Similar Questions
Enter the student details using constructors with arguments and constructors without arguments. Then find the total marks of each student. If it is greater than 500 print pass , else print fail.
Create a class Student with data members name,regno,CGPADefine a default constructor and read the values of the data members from the user.Define a member function inside the class that will print “eligible for placement “ if CGPA is greater than or equal to 8;else prints “ not eligible”.Create object and call the member function and print the results.Sample InputAkash12347Sample Output1234 Akash is not eligibleInputOutputProcessing InvolvedSolution AlternativesAlgorithm/ Pseudocode
The system records attendance details for multiple students, capturing their name, roll number, and attendance status for various subjects. Each subject has a total of 20 classes in a semester. Users can input the number of classes students have attended and calculate their attendance percentage. If a student's attendance falls below 75% for a particular subject, the system identifies it and calculates the number of classes they need to attend to reach a minimum of 75% before the semester concludes.Sample Input:Student Name: John DoeRoll Number: ABC123Subject: MathematicsClasses Attended: 15 Student Name: Jane SmithRoll Number: XYZ456Subject: PhysicsClasses Attended: 10 Sample Output:For John Doe (Roll Number: ABC123) in Mathematics:Attendance Percentage: 75%No additional classes required.For Jane Smith (Roll Number: XYZ456) in Physics:Attendance Percentage: 50%Additional classes needed: 5
Get a count of number of students. Get the input details from each student like 'name', 'address', ‘class number’ and ‘department’ till that particular count is reached.In the names of the student where the pattern “in” occurs. Replace it by ‘$$’.Using static member functions/static variable, assign a unique roll number to each student.Display all the student details. Implement the above process using java class and constructors.Ex: Stalin (pattern “in”)
Assume that you are given the details of n students (regno,name,Living City) and list of students who registered for python course. During vacation, your Faculty wants to conduct a physical coding contest for those who lives in Chennai. Help her to find regno of all students in ascending orderSample Input7BCE1001 Mahi DelhiBRS1082 Rathi ChennaiBRS1011 Ranjan HyderabadBRS1900 Kathir ChennaiBRS1901 Kavi APBCE1011 Mahitha UPBCE1111 Harish PunjabSample outputBRS1082BRS1900Use array of structures
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.