0% found this document useful (0 votes)
18 views2 pages

OOPS - Class-Practice Exercise

Uploaded by

Nishant Sinha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

OOPS - Class-Practice Exercise

Uploaded by

Nishant Sinha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Galgotias University

Greater Noida

Complex Programming Exercise Questions for BTCS 2404

Classes, objects

1. Define a class Rectangle. The class should contain sides: length and breadth of the rectangle as
the data members. It should support the following methods:
a) __init__ for initializing the data members: length and breadth.
b) setLength for updating the length of the rectangle.
c) setBreadth for updating breadth of the rectangle.
d) getLength for retrieving the length of rectangle.
e) getBreadth for retrieving the breadth of the rectangle.
f) area to find the area of the rectangle
g) perimeter for finding perimeter of the rectangle
2. Define the following methods for MyDate class – It has day, month, and year as integer data
members:
a) addDays – To add n days to the date.
b) addMonths – To add n months to date.
c) addYears – To add n years to date.
d) Weekday – To return weekday of the date.
e) diffDates – To find difference between two dates in terms of the years, months and days
f) futureDate – To find a future date after a given number of days, months, and years.
g) pastDate – To find a date in the past before a given number of days, months, and years.
3. Define a class Student that keeps track of academic record of students in a school. The class
should contain the following data members:
rollNum– Roll number of student
name – Name of student
marksList – List of marks in five subjects
stream – A: Arts, C:Commerce, S: Science
percentage- Percentage computed using marks
grade – Grade in each subject computed using marks
division – Division computed on the basis of overall percentage
The class should support the following methods:
a) __init__ for initializing the data members
b) setMarks to take marks for five subjects as an input from the user.
c) getStream for accessing the stream of the student
d) percentage for computing the overall percentage of the student
e) gradeGen that generates grades for each student in each course on the basis of the marks
obtained. Criteria for computing the grade is as follows:

Marks Grade
>= 90 A
<90 and >=80 B
<80 and >=65 C
<65 and >=40 D
<40 E
f) division for computing division on the basis of the following criteria based on overall
percentage of marks scored:
Percentage Division
>= 60 I
<60 and >=50 II
<50 and >= 35 III

g) __str__that displays student information.

You might also like