Write a class Student with the following attributes (make sure the attributes are private using name mangling):   name: String id : Integer courses: List of Strings grades: List of Integers The class must include the following operations:   A constructor that receives as input the name and id.  Getters for each attribute. add_course(course: String, grade: Integer) : Bool  --  This operation adds the course name to the list of courses and the grade to the list of grades. The method must confirm before adding that the course is a String and the grade is an Integer, otherwise the operation won't be performed. The method must return True if the course and grades were added, False otherwise.  __str__() -- Should return the following information "Student name: -- Courses passed: ". Courses passed means courses with a grade equal to 60 or larger. Check the testcase for details.  pass_ratio(): Float -- Returns the pass ratio as a percentage of the courses passed with respect to the total of courses (the percent must the rounded to two numbers after the digits). Check the testcase for details.  Note:  4 of 7 courses would be 4/7 = 0.57142857... which would be returned as 57.14 courses_from_file(filename: String) -- Reads the courses names and grades from a text file and adds them to the corresponding lists. The file has one course-grade per line separated by a semicolon. You can assume the filename passed as parameter does exist (i.e. you do not have to check if the file exists).

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter9: Using Classes And Objects
Section: Chapter Questions
Problem 19RQ
icon
Related questions
Question

Write a class Student with the following attributes (make sure the attributes are private using name mangling):

 

  • name: String
  • id : Integer
  • courses: List of Strings
  • grades: List of Integers

The class must include the following operations:

 

  • A constructor that receives as input the name and id. 
  • Getters for each attribute.
  • add_course(course: String, grade: Integer) : Bool  --  This operation adds the course name to the list of courses and the grade to the list of grades. The method must confirm before adding that the course is a String and the grade is an Integer, otherwise the operation won't be performed. The method must return True if the course and grades were added, False otherwise.
  •  __str__() -- Should return the following information "Student name: <name> -- Courses passed: <number of courses passed>". Courses passed means courses with a grade equal to 60 or larger. Check the testcase for details. 
  • pass_ratio(): Float -- Returns the pass ratio as a percentage of the courses passed with respect to the total of courses (the percent must the rounded to two numbers after the digits). Check the testcase for details.  Note:  4 of 7 courses would be 4/7 = 0.57142857... which would be returned as 57.14
  • courses_from_file(filename: String) -- Reads the courses names and grades from a text file and adds them to the corresponding lists. The file has one course-grade per line separated by a semicolon. You can assume the filename passed as parameter does exist (i.e. you do not have to check if the file exists).
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,