1) 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 :
(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 Rs. 1000 2% of price
More than Rs. 1000 and less than or equal to Rs. 3000 10% of price
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.
=================================================================
2) Design a class name ShowRoom with the following description :
Instance variables/ Data members :
String name – To store the name of the customer
long mobno – To store the mobile number of the customer
double cost – To store the cost of the items purchased
double dis – To store the discount amount
double amount – To store the amount to be paid after discount
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
Cost Discount (in percentage)
Less than or equal to ₹ 10000 5%
More than ₹ 10000 and less than or equal to ₹ 20000 10%
More than ₹ 20000 and less than or equal to ₹ 35000 15%
More than ₹ 35000 20%
void display() – To display customer name, mobile number, amount to be paid after discount.
Write a main method to create an object of the class and call the above member methods.
=================================================================
3) Define a class called with the following specifications:
Class name: EShop
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%
25001 - 57000 7.5%
57001 - 100000 10%
More than 100000 15%
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.
=================================================================
4) Define a class named MovieMagic with the following description:
Instance variables/data members:
int year — to store the year of release of a movie.
String title — to-store the title of the movie
float rating — to store the popularity rating of the movie
(minimum rating=0.0 and maximum rating=5.0)
Member methods:
(i) MovieMagic() Default constructor to initialize data members.
(ii) void accept() To input and store year, title and rating.
(iii) void display() To display the title of a movie and a message based on the rating as per the table below.
Rating Message to be displayed
0.0 to 2.0 Flop
2.1 to 3.4 Semi-hit
3.5 to 4.5 Hit
4.6 to 5.0 Super Hit
Write a main method to create an object of the class and call the above member methods.
=================================================================
5) An Electric shop has announced the following seasonal discounts on the purchase of following items:
Purchase amount Discount on mobile Discount on tablet
1-7000 5.0% 3.0%
7001-15000 8.5% 6.5%
More than 15000 20.0% 12.0%
Write a program to create functions
void product (long barcode, double amount, char type) to accept bar code number, amount of purchase and type of purchase i.e. M for Mobile and T for Tablet.
Calculate the discount and net amount
Print the bar code number, purchase amount, discount and net amount.
=================================================================
6) The telephone department compute monthly telephone bill using the give rules on the basic of calls:
Number of calls Rate
1st 100 calls Rs.250/- as rental charge
Next 100 calls 60p per call + rental charge
Next 100 calls 50p per call + rental charge
Any call above 300 calls 40p per call + rental charge
Write a program to input no. of calls and compute total bill amount. Print all data members.
=================================================================
7) Define a class called Bike with the following description:
Instance variables /data members:
int bno — to store the bike’s number
int phno — to store the phone number of the customer
String name — to store the name of the customer
int days — to store the number of days the bike is taken on rent
int charge — calculate and store the rental charge
Member methods:
void input() — to input and store the detail of the customer
void compute() — to compute the rental charge.
The rent for a Bike is charged on the following basis:
First five days ₹ 500 per day.
Next five days ₹ 400 per day.
Rest of the days ₹ 200 per day.
void display() — to display the details in the following format:
Bike Number Name Phone Number No. of Days Charge
---------------- ---------------- ---------------- ---------------- -------------
=================================================================
8) Define a class with the following specifications:
Class name: Employee
Member variables:
eno – Employee Number
ename – Name of the Employee
age – Age of the Employee
basic – Basic Salary
net – Net Salary
(Declare the variables using appropriate data types)
Member methods:
void accept() – accept the details using Scanner class
void calculate() – to calculate the net salary as per the given specifications:
net = basic + hra + da – pf
hra = 18.5% of basic
da = 17.45% of basic
pf = 8.10% of basic
If the age of the employee is above 50, he/she gets an additional allowance of ₹ 5000.
void print() – to print the details as per the following format:
Eno Ename Age Basic Hra Da Pf Net
void main() – to create an object of the class and invoke the methods.
=================================================================
9) Design a class RailwayTicket with following description:
Instance variables/s data members :
String name : To store the name of the customer
String coach : To store the type of coach customer wants to travel
long mobno : To store customer’s mobile number
int amt : To store basic amount of ticket
int totalamt : To store the amount to be paid after updating the original amount
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
Type of Coaches Amount
First Class 700
Second_AC 500
Third _AC 250
sleeper None
void display( ) — To display all details of a customer such as name, coach, total amount and mobile number.
Write a main method to create an object of the class and call the above member methods.
=================================================================
10) Define a class ElectricBill with the following specifications:
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
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 :
· First 100 Units: ₹10/- unit
· Next 100 units: ₹15/- unit
· Next 100 units: ₹20/- unit
· above 300 units ₹25/- unit
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.
=================================================================
11) Given below is a table showing rates of Income Tax:
Taxable Income (TI) in Rs. Income Tax in Rs.
Does not exceed Rs. 1,60,000 Nil
1,60,000 - Rs. 5,00,000 (TI—1,60,000) × 10%
Rs. 5,00,000 - Rs. 8,00,000 [(TI—5,00,000) × 20%] + 34,000
Is greater than Rs. 8,00,000 [(TI—8,00,000) × 30%] + 94,000
Write a program to input the age, Taxable Income of a person.
Compute and display the Income Tax payable as per the table given above.
=================================================================
12) Write a program in Java to Design a class IncomeTax as follows:
Class Name : IncomeTax
Instance variables/Data members
name : Name of the Employee
monthlyincome : Monthly income
annualsalary : Calculate the Annual Salary
incometax : Income Tax payable
Member methods
Default constructor to iniliatize the instance variables
void getData() : to accept the age, monthly salary
void incomeTax() : : to calculate the tax payable
void showData() : to show the name of the Employee, Monthly salary, Annual salary, and Amount tax payable.
0 - Rs 3,00,000 0%
Rs 3,00,001 Rs 7,00,000 5%
Rs 7,00,001 Rs 10,00,000 10%
Rs 10,00,001 Rs 12,00,000 15%
Rs 12,00,001 Rs 15,00,000 20%
Rs 15,00,001 and above 30%
=================================================================