Professional Documents
Culture Documents
Adobe Scan 02 Jul 2023
Adobe Scan 02 Jul 2023
(i ) void Dok
(ii) BookEair(String x, double y)-Parameterized constructor to initialize the data members.
the priceof the hook
(i)void input() - To input and store the name and
(i)yoid calculate() -To calculate the price after discount. Discount is calculated based on
the following criteria.
Discount
Price
Less than or equal to Rs.1000 2% of price
More than Rs. 1000 and less than 10% of price
or equalto Rs. 3000
More than Rs. 3000 15% of price
discount.
(iv) void display() - To display the name and price of the book after member methods.
Write a main method to create an object of the class and call the above
Question 9
Define a class PhoneBill with the following descriptions: [10]
Data Members:
CustomerName String
phoneNumber long
no of units int
rent int
amount float
Member functions:
1. A
constructor toassign initial values of customerName as "Raju", phoneNumber as
259461, no of units as 50, rent as 100, amount as 100.
2. calculate() :This member function should calculate the value of amount as rent + cost
for the units.
Where cost for the units can be calculated according to the following conditions:
No _of_units Cost
First 50 calls free
Next 100 calls 0.80 @ unit
Next 200 calls 1.00 @ unit
Remaining calls 1.20 @ unit
3. Afunction accept() which allows user to enter customerName ,phoneNumber,
no of units and rent and should callfunction calculate().
4. A function display() todisplay the value of all the data members on the screen