L1 Practice
L1 Practice
1. In a company an employee is paid as under: If his basic salary is less than Rs.
15000, then HRA = 1000 of basic salary. If his salary is either equal to or above
Rs. 15000, then HRA = Rs. 500 of basic salary. If the employee's salary is input
through the keyboard write a program to find his gross salary
2. A cashier has currency notes of denominations 10, 50 and 100. If the amount to
be withdrawn is input through the keyboard in hundreds, find the total number of
currency notes of each denomination the cashier will have to give to the
withdrawer.
4. Arun has got a new debit card, he must set the pin of the credit card with the
following conditions, the pin number should be even and divisible by 5. Help Arun
set a pin for his debit card.
Hint: Ask user to enter any two/three-digit pin number check if it is even and
divisible by 5 and display if it can be used as pin for the card
5. Revenue can be calculated as the selling price of the product times the quantity
sold, i.e. revenue = price × quantity. Write a program that asks the user to enter
product price and quantity and then calculate the revenue. If the revenue is more
than 5000 a discount is 10% offered. The program should display the discount and
net revenue.
6. Create a Java class named Bank with methods credit and debit to simulate a
simple bank account. The credit method should allow you to insert an amount into
the account, and the debit method should allow you to withdraw an amount from
the account. After each process, display the current balance. Create an object of
the Bank class, perform a credit operation to insert an amount, then perform a debit
operation to withdraw an amount, and display the updated balance. Note: Assume
that the Bank class has already been defined with the necessary attributes and
methods.
7. Alliance University Admission section needs software to maintain students'
records, Create class Student Admission. In Student Admission, Registration takes
place, read input (Student: Name, Age and Department). Finally, to display
Admission No (Auto generation), Name, Age, department using class and object.
8. Create a class called Patient. Read the pid, p_no_of_days, p_room. Initialize the
one-time charges for patient admision as 500 Rs. If the room type is special the
cost per day is 5000 Rs and if room type is general cost per day is 1000 Rs.
Calculate the overall bill of the patient depending upon his stay in hospital.
Example: given only for one patient
9. Suppose you have a Piggie Bank with an initial amount of ₹50 and you have to
add some more amount to it. Create a class 'AddAmount' with a data member
named 'amount' with an initial value of ₹50. Now make two constructors of this
class as follows:
1 - without any parameter - no amount will be added to the Piggie Bank and the
balance is ₹50 only.
2 - having a parameter which is the amount that will be added to Piggie Bank by
giving the input from the user.
Create object of 'AddAmount' class and display the total amount in Piggie Bank.
10. Prabhu is looking to buy a new bicycle. So, he asked many people in his friends
and family. They give the features of a bicycle like gear and speed. Create a class
named ‘Bicycle’ with the data members ‘gear’ and ‘speed’. Now make three
constructors of this class as follows:
• Without any parameter – Assign some default values to the instance variables
and display it
• Passing one parameter-Assign ‘gear’ value is ‘0’ and the parameter will be
assigned to the ‘speed’ variable
• Passing two parameters- Assign both values to the instance variables and
display it.