Adobe Scan May 02, 2025
Adobe Scan May 02, 2025
Member Methods:
Write a main method to create an object of the class and call the above member methods. [15]
Define a class ElectricBill with the following specifications: [15)
class ElectricBill
Instance variables / data member:
String n-to store the name of the customer
int units - to store the number of units consumed
double bill -to store the amount to be paid
Membet methods:
void accept() - to accept the name ofthecustomer and number of units consumed
void calculate( ) to calculate the bill as per the following tarif:
Number of units Rate per unit
First 100 units Rs.2.00
Next 200 units Rs.3.00
Above 300 units Rs.5.00
A surcharge of 2.5% charged if the number of units consumed is above 300 units.
void print ()- To print the details as follows:
Name of the customer:
Number of units consumed:
Bill amount:
Write a main method to create an object of the class and call the above member
methods.
Define a class named BookFair with the following description : [15]
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 initialize data members
(ii) void nput() To input and store the name and the price of the book.
(ii) void calculate() To calculate the price after discount. Discount is calculated
based on the following criteria
Price Discount
void calculate) - To compute the parking charge at the rate of 3for the first hour or part
thereof, and1.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. [13]
Questio.
Design a class RailwayTicket with following description: [15]
Instance variables/data members