ASSIGNMENT
COMPUTER APPLICATION
CLASS -X
1. Write a program to input the basic salary of a person. He gets 15% of the basics as HRA, 15%
of the basics as Conveyance allowance and 10% of the basic as Entertainment allowance. The
total salary is calculated by adding Basic + HRA + Conveyance + Entertainment Allowance.
Calculate and print the total salary of a person.
2. Write a program to input employee name and his salary of a month and print his annual
salary. (Stream Class)
3. Write a program to find the difference between Compound Interest and Simple Interest.
(Functional Argument)
4. Write a program to input two integers using Scanner and find the product of their sum and
difference. (Scanner Class)
5. Write a program to find the value of the given expression P = (a2+b2) / (a – b). (Input using
Command line arguments)
6. Write a program to input a number and check and print whether it is a Pronic number or not.
(Pronic number is the number which is the product of two consecutive integers)
7. Write a program to accept a number and check and display whether it is a spy number or
not. (A number is spy if the sum of its digits equals the product of its digits.
8. Write a program to input two unequal positive numbers and check whether they are perfect
square numbers or not.
9. Write a program to accept a number then check whether the given number is Armstrong number or
not. (E.g. 153 is a Armstrong number because 153 = 13 + 53 +33).
10. Write a program to display first 10 terms of the following series: 2, 5,10,17, 26…..
11. Write a program to check if the number entered by user is prime or not.
12. Using switch-case write a menu driven program to i) Area of a right-angled triangle,
ii) Area of a square, iii) Area of rectangle.
13. Using a switch statement, write a menu driven program to convert a given temperature from
Fahrenheit to Celsius and vice versa. For an incorrect choice, an appropriate error message
should be displayed.
(HINT: C = 5 9 × (F − 32) and F = 1.8 × C + 32)
14. 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) input() - To input and store the name and the price of the book.
(ii) 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 equal to ` 3000 10% of price More than ` 3000 15% of price
ASSIGNMENT
COMPUTER APPLICATION
CLASS -X
(iii) display() - To display the name and price of the book after discount.
Write a main() to create an object of the class and call above member methods.
15. Define a class ‘Student’ described as below:
Data members/instance variables:
name, age, m1, m2, m3 (marks in 3 subjects), maximum, average Member methods:
16. i. To accept the details of a student.
ii. To compute the average and the maximum out of three marks.
iii. To display the name, age, marks in three subjects, maximum and
average.
Write a main method to call the above member methods.
17. Define a class busfare having the following description: Data members/instance variables:
int busno - to store bus number
String name - to store passenger’s name
int km - to store number of kilometers travelled.
Member functions:
input() - - to store bus number, name, km
calculate() - - to calculate bill for a customer according to given conditions
i) Up to 5km: distance X 4
ii) 6 to 15 km: first compute 5kms fare then (distance – 5) X 6.
iii) 16 km and above: first compute 5 kms fare then compute 10 kms fare and then compute
(distance – 15 ) X 8
display() - - To display the details in the following format.
Busno || Name || KilometersTravelled || Bill amount ||
18. Write a program to accept a word and print whether the word is a palindrome or not.
19. Write a program using the switch statement, write a menu driven program for the following:
(a) To print the Floyd’s triangle:
(b) To display the following pattern:
I
IC
ICS
ICSE
20. Write a JAVA program to display the following pattern
A
BB
CCC
DDDD
EEEEE
ASSIGNMENT
COMPUTER APPLICATION
CLASS -X
21. Write a JAVA program : The method takes an integer argument n and prints the following pattern
(n=4)
a
a a
a a a
a a a a
a a a
a a
a
22. Write a program to accept a mark obtained by a student in computer science and print the
grades accordingly:
Marks Grade
Above 90 A
70 to 89 B
50 to 69 C
below 50 D
23. Write a Java program to implement binary search.
24. Write a Java program to implement selection sort.
25. Write a Java program to implement bubble sort.