Create a base class External_exam with protected member : marks( out of 100)Create a constructor to read the marks.Create another base class Internal_exam with private members: cat1,cat2Create a constructor to read cat1 and cat2 marks(out of 50).Create a derived class exam from above 2 classes with member function : DA1,DA2,DA3Create a constructor to read DA1,DA2,DA3 marks(out of 10).Create a member function to calculate the total mark T.T=(0.40*marks)+(0.15*cat1)+ (0.15*cat2)+ DA1,DA2,DA3.Internal marks is (0.15*cat1)+ (0.15*cat2)+ DA1,DA2,DA3External mark is 0.40*marksSample Input78 (marks)34(cat1)28(cat2)9(da1)9(da2)8(da3)Sample OutputInternal:35.30External:31.20Total:66.50
Question
Create a base class External_exam with protected member : marks( out of 100)Create a constructor to read the marks.Create another base class Internal_exam with private members: cat1,cat2Create a constructor to read cat1 and cat2 marks(out of 50).Create a derived class exam from above 2 classes with member function : DA1,DA2,DA3Create a constructor to read DA1,DA2,DA3 marks(out of 10).Create a member function to calculate the total mark T.T=(0.40marks)+(0.15cat1)+ (0.15cat2)+ DA1,DA2,DA3.Internal marks is (0.15cat1)+ (0.15cat2)+ DA1,DA2,DA3External mark is 0.40marksSample Input78 (marks)34(cat1)28(cat2)9(da1)9(da2)8(da3)Sample OutputInternal:35.30External:31.20Total:66.50
Solution 1
This problem seems to be a task for creating classes in Python. Here is the step-by-step solution:
# Base class External_exam
class External_exam:
def __init__(self, marks):
self._marks = marks # protected member
# Base class Internal_exam
class Internal_exam:
def __init__(self, cat1, cat2):
self.__cat1 = cat1 # private member
self.__cat2 = cat2 # private member
# getter methods for private members
def get_cat1(self):
return self.__cat1
def get_cat2(self):
return self.__cat2
# Derived class exam
class Exam(External_exam, Internal_exam):
def __init__(self, marks, cat1, cat2, da1, da2, da3):
External_exam.__init__(self, marks)
Internal_exam.__init__(self, cat1, cat2)
self.da1 = da1
self.da2 = da2
self.da3 = da3
def calculate_total_mark(self):
internal = 0.15*self.get_cat1() + 0.15*self.get_cat2() + self.da1 + self.da2 + self.da3
external = 0.40*self._marks
total = internal + external
return internal, external, total
# Sample Input
e = Exam(78, 34, 28, 9, 9, 8)
internal, external, total = e.calculate_total_mark()
# Sample Output
print("Internal: {:.2f}".format(internal))
print("External: {:.2f}".format(external))
print("Total: {:.2f}".format(total))
This code first defines the base classes External_exam and Internal_exam with their respective members and constructors. Then it defines the derived class Exam which inherits from both base classes and adds its own members and methods. The calculate_total_mark method calculates the total mark according to the given formula. The sample input and output demonstrate how to use these classes.
Solution 2
This problem is about creating classes and calculating marks in Python. Here is the step by step solution:
class External_exam:
def __init__(self, marks):
self._marks = marks
class Internal_exam:
def __init__(self, cat1, cat2):
self.__cat1 = cat1
self.__cat2 = cat2
def get_cat1(self):
return self.__cat1
def get_cat2(self):
return self.__cat2
class Exam(External_exam, Internal_exam):
def __init__(self, marks, cat1, cat2, da1, da2, da3):
External_exam.__init__(self, marks)
Internal_exam.__init__(self, cat1, cat2)
self.da1 = da1
self.da2 = da2
self.da3 = da3
def calculate_total_mark(self):
internal = (0.15*self.get_cat1()) + (0.15*self.get_cat2()) + self.da1 + self.da2 + self.da3
external = 0.40*self._marks
total = internal + external
return internal, external, total
# Sample Input
e = Exam(78, 34, 28, 9, 9, 8)
internal, external, total = e.calculate_total_mark()
# Sample Output
print("Internal: {:.2f}".format(internal))
print("External: {:.2f}".format(external))
print("Total: {:.2f}".format(total))
In this code, we first create the base classes External_exam and Internal_exam with their respective members and constructors. Then, we create the derived class Exam from these two base classes. In the Exam class, we have a member function calculate_total_mark to calculate the total mark. Finally, we create an instance of the Exam class with the sample input, calculate the total mark, and print the output.
Similar Questions
We want to calculate the total marks of each student of a class in Physics,Chemistry and Mathematics and the average marks of the class. The number of students in the class are entered by the user. Create a class named Marks with data members for roll number, name and marks. Create three other classes inheriting the Marks class, namely Physics, Chemistry and Mathematics, which are used to define marks in individual subject of each student. Roll number of each student will be generated automatically using inheritance by c++
Create a class VIT with data members student roll no, name, marks define a constructor to initilize the data members create a derived class student ,define a member function to calculate the average mark of the student
Write a C program using structure student which allows users to input details for three students including their names, roll numbers, and marks in 5 subjects. Use a function calculateTotalMarks(struct Student) which calculates the total marks and percentage for each student and displays the information. Each subject test is for 10 marks. Total marks = 50. Percentage = (marks obtained/total marks)*100.
Develop the Internal mark calculation system based on the attendance percentage using Java. Get the student name, register number, total number of working days in the semester and Number of days present. Calculate attendance percentage of the students and award attendance mark based on the following condition. Attendance percentage >=90 – 5 MarksAttendance percentage >=80 and < 90 – 4 MarksAttendance percentage >=75 and < 80 – 3 MarksAttendance percentage < 75 - 0 MarksImplement using inheritance
Create a class called "Student" with private member variables for name, roll number, and marks in three subjects. Include public member functions to set the student details, calculate the average marks, and display the student detail
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.