Ch#11 Constructors
Ch#11 Constructors
Data Members/
Purpose
Instance Variables
Pg.1
Member Methods/
Purpose
Member Functions
Pg.2
2. Define a class named MovieMagic with the following
description: [ICSE -2014]
Member Methods/
Purpose
Member Functions
Pg.3
Rating Message to be displayed
Pg.4
Rating Message to be displayed
Price Discount
Pg.5
Price Discount
15% of
More than ₹3000
price
(iv) void display() — To display the name and price of the book
after discount.
Discount (in
Cost
percentage)
Pg.6
Discount (in
Cost
percentage)
Pg.7
Ticket Amount Discount
Write a program to input the name and ticket amount for the
customer and calculate the discount amount and net amount to be
paid.
Pg.8
Member Methods/
Purpose
Member Functions
Days Charge
Output:
Pg.9
Instance Variables/Data Members:
(a) int accNum — stores the accession number of the book.
(b) String title — stores the title of the book.
(c) String author — stores the name of the author.
(a) void input() — To input and store the accession number, title
and author.
(b) void compute() — To accept the number of days late,
calculate and display the fine charged at the rate of Rs. 2 per
day.
(c) void display() — To display the details in the following
format:
Accession Number Title Author
Pg.10
(c) void display() — To display the detail.
Write a main() method to create an object of the class and call
the above methods.
First_AC 700
Second_AC 500
Third_AC 250
sleeper None
Pg.12
Write a main method to create an object of the class and call
the above member methods.
(a) void accept() — Accept name, age and marks using methods
of Scanner class.
(b) void allocation() — Allocate the stream as per following
criteria:
mks stream
(c) void print() – Display student name, age, mks and stream
allocated.
Pg.13
Call all the above methods in main method using an object.
(a) void accept(): Accept the name and the price of the item
using the methods of Scanner class.
Price Discount
(c) void display(): To display the name of the item and the net
amount to be paid.
Write the main method to create an object and call the above
methods.
III. Parameterized Constructor
Pg.14
1. Define a class Student as given below:[ICSE – 2010]
Data members/Instance variables:
name, age, m1, m2, m3 (marks in 3 subjects), maximum, average
Member methods /Member Functions:
Pg.15