orkSheet
W
S td. : X Sub.: Computer Science Topic : Java programs.
Name: ______ Div. ___ Roll No: ___
rite a program by using class 'Employee' to accept Basic Pay of an employee. Calculate the
W
allowances/deductions as given below.
llowance / Deduction
A Rate
Dearness Allowance (DA) 30% of Basic Pay
House Rent Allowance (HRA)15% of Basic Pay
Provident Fund (PF) 12.5% of Basic Pay
Finally, find and print the Gross and Net pay.
Gross Pay= Basic Pay + Dearness Allowance + House Rent Allowance
Net Pay= Gross Pay - Provident Fund
_______________________________________________________________________________
A shopkeeper offers 10% discount on the printed price of a Digital Camera. However, a customer has
to pay 6% GST on the remaining amount. Write a program in Java to calculate the amount to be paid
by the customer taking printed price as an input.
Using the switch statement, write a menu-driven program to calculate the maturity
amount of a bank deposit.
The user is given the following options:
(i) Term Deposit
(ii) Recurring Deposit
For option (i) accept Principal (p), rate of interest (r) and time period in years (n).
Calculate and output the maturity amount (a) receivable using the formula
a = p(1 + r / 100)n.
For option (ii) accept monthly installment (p), rate of interest (r) and time period in
months (n). Calculate and output the maturity amount (a) receivable using the formula
a = p * n + p * n(n + 1) / 2 * r / 100 * 1 / 12.
For an incorrect option, an appropriate error message should be displayed.
__________________________________________________________________________________
Write a program to input the time in seconds. Display the time after converting them into hours,
minutes and seconds.
Sample Input: Time in seconds 5420
Sample Output: 1 Hour 30 Minutes 20 Seconds
_______________________________________________________________________________
Write a program in Java to accept a word/a String and display the new string after removing
all the vowels present in it.
Sample Input: COMPUTER APPLICATIONS Sample Output: CMPTR PPLCTNS
rite a program to input three numbers and check whether they are equal or not. If they are
W
unequal numbers then display the greatest among them otherwise, display the message 'All the
numbers are equal'.
Sample Input: 34, 87, 61
Sample Output: Greatest number: 87
Sample Input: 81, 81, 81
Sample Output: All the numbers are equal
A Pre-Paid taxi charges from the passenger as per the tariff given below:
Distance Rate
Up to 5 km ₹ 100
For the next 10 km ₹ 10/km
For the next 10 km ₹ 8/km
More than 25 km ₹ 5/km
Write a program to input the distance covered and calculate the amount paid by the passenger. The
program displays the printed bill with the details given below:
Taxi No. :
Distance covered :
Amount :
_________________________________________________________________________________
efine a class to input 15 integer elements in an array and sort them in
D
ascending order using the bubble sort technique.
_ ________________________________________________________________________________
Write a program to input and store integer elements in a double dimensional
array of size 4 x 4 and find the sum of all the elements.
7 3 4 5
5 4 6 1
6 9 4 2
3 2 7 5
Sum of all the elements: 73
_________________________________________________________________________________
cloth showroom has announced festival discounts and the gifts on the purchase of items, based
A
on the total cost as given below:
Total Cost Discount Gift
Up to ₹ 2,000 5% Calculator
₹ 2,001 to ₹ 5,000 10% School Bag
₹ 5,001 to ₹ 10,000 15% Wall Clock
Above ₹ 10,000 20% Wrist Watch
Write a program to input the total cost. Compute and display the amount to be paid by the customer
along with the gift.
________________________________________________________________________________
efine a class to enter a sentence from the keyboard and count the number of times a
D
particular word occurs in it. Display the frequency of the search word.
E.g.
Input : Enter the sentence:
Hello, this is wow world
Enter the word:
wow
Output:
Searched word occurs 1 times.
_______________________________________________________________________________________
Write a program to input a number. Check and display whether it is a Niven number or not. A
number is Niven if it is divisible by the sum of its digits.
e.g. Input: 126
Output: 1 + 2 + 6 = 9 and 126 is divisible by 9.
____________________________________________________________________________________
Define a class to performbinary searchon a list of integers, to search for an
Element input by the user, if it is found display the element along with its position, otherwise
display the message "Search element not found".