Class and Object Programs-Past Papers
Class and Object Programs-Past Papers
Member methods:
Write a main method to create an object of a class and call the above member
methods.
Days Charge
For first five days ₹500 per day
For next five days ₹400 per day
Rest of the days ₹200 per day
Output:
Bike No. Phone No. Name No. of days Charge
xxxxxxx xxxxxxxx xxxx xxx xxxxxx
3. 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 author — stores the name of the author.
Member methods:
1. void input() — To input and store the accession number, title and author.
2. void compute() — To accept the number of days late, calculate and
display the fine charged at the rate of Rs. 2 per day.
3. void display() — To display 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 methods.
Member Methods:
void input() — To input and store the vno and hours.
void calculate() — To compute the parking charge at the rate of ₹3 for the first
hour or part thereof, and ₹1.50 for each additional hour or part thereof.
void display() — To display the detail.
Write a main() method to create an object of the class and call the above
methods.
Member methods:
(i) BookFair() — Default constructor to initialize data members
(ii) void Input() — To input and store the name and the price of the book.
(iii) void calculate() — To calculate the price after discount. Discount is
calculated based on the following criteria.
Price Discount
Less than or equal to ₹1000 2% of price
More than ₹1000 and less than or 10% of price
equal to ₹3000
More than ₹3000 15% of price
(iv) void display() — To display the name and price of the book after discount.
Write a main method to create an object of the class and call the above
member methods.
class : ElectricBill
Member methods:
void accept( ) — to accept the name of the customer and number of units
consumed
void calculate( ) — to calculate the bill as per the following tariff:
Write a main method to create an object of the class and call the above
member methods.
Member methods:
void accept() — To take input for name, coach, mobile number and amount.
void update() — To update the amount as per the coach selected (extra amount
to be added in the amount as follows)
Write a main method to create an object of the class and call the above
member methods.
Member methods:
ShowRoom() — default constructor to initialize data members
void input() — To input customer name, mobile number, cost
void calculate() — To calculate discount on the cost of purchased items,
based on following criteria
Member variables:
name — name of student
age — age of student
mks — marks obtained
stream — stream allocated
Member methods:
void accept() — Accept name, age and marks using methods of Scanner class.
void allocation() — Allocate the stream as per following criteria:
mks stream
>= 300 Science and Computer
>= 200 and < 300 Commerce and
Computer
>= 75 and < 200 Arts and Animation
< 75 Try Again
void print() – Display student name, age, mks and stream allocated.
Member variables:
String name: name of the item purchased
double price: Price of the item purchased
Member methods:
void accept(): Accept the name and the price of the item using the methods of
Scanner class.
void calculate(): To calculate the net amount to be paid by a customer, based
on the following criteria:
Price Discount
1000 – 25000 5.0%
25001 – 57000 7.5 %
57001 – 100000 10.0%
More than 100000 15.0 %
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.