Page 233 - computer science (868) class 11
P. 233
Data Members
int m,n : m and n is the upper and lower limit of the range
Member Methods
void accept(int a, int b) : Assigns a to m and b to n
void display() : Prints all the palindromic_prime numbers from m to n.
9. Define a class named BookFair with the following description:
Instance variables/data members:
String bName : Stores the name of the book
double price : Stores the price of the book
Member Methods
BookFair() : Default constructor to initialise data members.
void input() : Inputs and stores the name and the price of the book
void calculate() : Calculates the price after discount
Discount is calculated based on the following criteria:
Price Discount
Less than or equal to ` 1000 2% of the price
More than ` 1000 and less than
or equal to ` 3000 10% of the price
More than ` 3000 15% of the price
void display() : Displays the name and price of the book after discount
10. Define a class called Library with the following description:
Instance variables/Data members
int accNum : Stores the accession number of the book
String title : Stores the title of the book
String auhor : Stores the name of the author
Member Functions
void input() : Accepts and stores the accession number, title and author
void compute() : Accepts the number of days late, calculates and displays the fine charged at the rate of Rs. 2 per day
void display() : Displays the details in the following format
Accession Number Title Author
_____ _____ _____
Write a main() method to create an object of the class and call the above member functions.
11. Define a class Discount having the following specifications.
Data Members
int cost : Stores the MRP of the item
String name : Stores the name of the item
doble dc : Stores the discount
double amt : Stores the amount to be paid
Member Methods
void accept() : Inputs the name and MRP of the item
void find() : Calculates the discount according to the following criteria
List Price Rate of discount
Up to ` 5000 No Discount
From ` 5001 to ` 10000 10% on the price
From ` 10001 to ` 15000 15% on the price
Above ` 15000 20% on the price
Output:
Name of the customer Discount Amount to be paid
_____ _____ _____
231
Methods and Constructors 231

