SlideShare a Scribd company logo
1 of 19
1
List of
Programs
to Practice
2
Simple programs using mathematical operators
1. Write a program to accept two numbers find and display the sum of two numbers.
2. Write a program to accept two sides of a rectangle. Compute and display the area and the
perimeter of the rectangle.
3. Write a program to accept the radius of a circle. Compute and display the area and the
circumference of the circle.
4. Write a program to accept the temperature in Celsius. Compute and display the equivalent
temperature in Fahrenheit. [ f=9*c/5+32 ]
5. Write a program to accept two sides of a rectangle. Compute and display the length of the
diagonal of the rectangle.
6. Write a program to accept the Principal, rate of interest and time. Compute and display the
Amount, the Compound Interest and Simple Interest.
7. Write a program to accept three numbers. Compute and display the sum and the average of the
three numbers.
8. A Computer manufacturing Company announces a special offer to their customer on purchasing
Laptops and the Printers accordingly:
On Laptop: Discount - 15%
On Printers: Discount - 10%
Write a program to accept the purchase price of Laptop and Printer, calculate the discount and
display the net amount the customer will pay on his purchase.
9. In an election, two candidates A and B contested. A got 60% of the votes. Write a program to
accept the total number of votes and calculate the number of votes each candidate got and
display the result.
10. Write a program to accept the length of the perpendicular and base of a right angled triangle.
Calculate and display the hypotenuse and area of the triangle.
11. Write a program to accept the basic pay of an employee, Compute and display the net pay of the
employee based on following allowances and deductions:
Dearness Allowance 25% of Basic Pay
House Rent Allowance 15% of Basic Pay
Provident Fund 10% of Basic Pay
Gross Pay = Basic Pay + Dearness Allowance + House Rent Allowance
Net Pay = Gross Pay – Provident Fund
12. Write a program to accept three sides of a triangle. Compute the area of the triangle using Hero’s
formula i.e. area of a triangle = √s(s-a)(s-b)s-c) where s=( a + b + c)/2. Display the result.
13. Write a program to calculate the value of x and y if x= a2 + b3 and y = b3 – a2 where value of ‘a’
and ‘b’ is to be given as input.
14. Write a program to accept the purchase price of a TV and calculate the selling prices of TV which
will give the shop keeper 15% profit and a loss of 5%. Display the selling prices in both the
cases.
15. Write a program to accept the present population of a country and calculate the population after
7 years if the growth rate is 7% per year. Display the population at the end of 7th year.
16. Write a program to accept a number of seconds as input and convert the number to the
corresponding number of hours, minutes and seconds and display it.
17. WAP to calculate the distance travelled by a person in the hours given as input, taking average
speed of travelling as 40Km per hour.
18. Write a program to input the purchase price of a TV and display the price customer will pay. The
shopkeeper allows 10% discount on purchase price and charges tax 12.5% on the net amount.
19. Write a program to input the input product code, price of product, quantity of product. Calculate
the total cost and discount 12% on total cost. Find the net price to be paid for the product. Print
all the data as output.
20. Write a program to swap the value stored in n1 and n2. Print the value before and after they are
interchanged.
21. Write a program to input the total monthly income. Find the total income, tax discount 20% of
the total income. Find total taxable income and sales tax at 15% of the taxable income. Display
the net income.
Programs using conditional statement – if ….. else statements
1. Write a program to accept any three numbers. Display the greatest among them.
2. Write a program to accept any three numbers and display the smallest number among them
using nested if statement.
3. Write a program to accept any number and check if the number is odd or even.
4. Write a program to accept three numbers and check whether they are Pythagorean Triplet or not.
The program must display message accordingly.
3
5. Write a program to accept any year and check if it is a leap year number or not.
6. WAP to input any year from 1000 to 2005 and print the number of days in that year.
7. WAP to accept three sides of a triangle and check whether the triangle is possible or not.
8. Write a program to accept the sides of a triangle and display whether it is an Equilateral or
Isosceles or a scalene triangle.
9. Write a program to accept the cost price and the selling price of an article and calculate either
profit percent or loss percent.
10. Write a program to accept any three digits number and count the numbers of odd digits present
in it. If odd digits are not found display appropriate message.
11. Write a program to accept a three digit number and form the biggest number using the digits of
the number and display the new number.
12. A bank offers the following denominations of notes:
` 500, ` 100, ` 50, ` 20, `10, `5, ` 2, ` 1
Write a program to accept the amount of money to be withdrawn and find out the number of notes of
each denomination to be given by the bank.
13. Write a program to accept any number below 10000 and display the amount to be added to it to
make the biggest number having same number of digits as of the number given as input. Use if
else ladder to solve the problem.
14. Write a program to accept the class in which a student is taking admission and display the tuition
fees he would have to pay per month using the table below:
CLASS Tuition Fee per month
1 to 3 Rs. 500/-
4 to 7 Rs. 600/-
8 to 10 Rs. 950-/.
15. Write a program to calculate the library fine for the books returned late as per the following rules
of the library:
up to 5 day Rs. 0.40 per day
Next 5 days Rs. 0.65 per day
Above 10 days Rs. 0.80 per day
16. Write a program to check if a three digit number is a Armstrong number or not
17. In a firm employee is paid as follows:
S.No. Basic Salary DA HRA
-------------------------------------------------------------------------------------
1. Less than 2000 10% 5%
2. Greater than equal to
2000 but less than 4000 25% 15%
3. Greater than equal to
4000 but less than 8000 30% 25%
4. greater than 8000 40% 30%
--------------------------------------------------------------------------------------
Write a program to accept the Basic salary and calculate the gross salary and net salary aft er
making following deductions: 1. P.F. at 10% of Basic Salary
2. I.T. at 2% of Basic Salary
Display Gross Salary and Net Salary.
18. WAP to accept value of a, b, c and compute the roots and display following results.
If b2 - 4ac results a positive answer display “REAL AND DISTINCT ROOTS”
If b2 - 4ac results a negative answer display “IMAGINARY ROOTS”
If b2 - 4ac results 0 display “REAL AND EQUAL ROOTS”
19. Write a java program to find the solution of any pair of linear simult aneous equation as follows:
ax + by = c
px + qy = r
The program should:
(i) accept values of a, b, p, q and r.
(ii) Use x = (cq – br)/ aq – bp) and
y = (ar – cp)/aq – bp)
(iii) print “No finite solution” if aq – bp = 0.
20. During sale a shop offers discount on the total purchases made by any customer. If the purchase
is less than Rs. 1000.00 the rate of discount is only 5%, for purchase from Rs. 1000.00 to
4999.00 rate of discount is 10% and purchase of Rs.5000.00 and above the rate of discount is
4
15%. Write a program to input the purchase amount and find the discount and amount to paid
by the customer.
21. Write a program to calculate the Telephone bill according to the following rules:
i. Minimum of Rs.250.00 is charged as rent.
ii. First 80 calls FREE
iii. Next 60 call @ Rs.0.60
iv. Next 60 call @ Rs.0.50
v. Above 200 call @ Rs.0.40
22. Write a program to calculate electricity bill for the number of units consumed given as input,
following the rules given below Minimum Meter rent charges Rs.100.00
Up to 250 units Rs.0.80 per unit
Above 250 units Rs.1.50 per unit
23. Given three numbers A, B and C, Write a program to write their value in an ascending order. For
Example, if A=12, B=10 and C=15, your program should print out as under
Smallest Number = 10
Next higher number = 12
Highest Number = 15
24. In an office there are three grades of employees, namely, A, B and C. Write a program to accept
the Pay and the Grade and calculate bonus obtained by them as per following rules:
For grade A Bonus = 10% of Pay
For grade B Bonus = 12% of Pay, subject to maximum of Rs.2000.00
For grade C Pay up to Rs.5000.00 5% of Pay
Pay above Rs.5000 to Rs.8000 7% of Pay
Pay above Rs. 8000.00 10% of Pay
25. Write a program in Java to calculate the income tax paid by Mr. Kartar Singh to the Govt. of India
on his annual income as per the slab given below:
Slab Income Tax
Up to Rs. 50,000 No Tax
Rs.50,001 to Rs.60,000 10% of the amount exceeding Rs.50,000/-
Rs.60,001 to Rs.1,50,000 Rs.1000 + 20% of the amount exceeding Rs.60,000/-
Rs.1,50,000 and above Rs.19,000 + 30% of the amount exceeding Rs.1,50,000/-
Take annual salary as input and display the income tax to be paid by him.
26. Write a program to compute charges for sending parcels when the charges are as follows: For
the first 1000gms Rs.15.00 and for additional weight of every 500gms or fraction thereof Rs.8.00.
Accept the total weight of the parcel and display the charges
27. A security agency pays to their staff as per the tariff given below:
Hours Rate
For first 48 hours in a week Rs. K per hour
For next 8 hours in a week Rs.1.25K per hour
For further hours in a week Rs.1.50K per hour
Write a program in Java to calculate the weekly wages of the staff taking number of hours and
rate per hour as inputs.
28. Write a program that displays the number of notes in each of the denominations i.e. number of
1000 rupees not, number of 500 rupees notes, number of 100 rupees notes Till number of 5
rupees note, for a given amount.
29. DTDC courier service charges for the transportation of any parcel within eastern zone as follows:
Up to 100gms. : Rs.30.00
For each additional 50gms.or part thereof : Rs.10.00
Write a program to calculate the charges of a parcel taking the weight of the parcel as an input.
30. ABC Limited revised its rate of interest for public deposits as follows:
YEARS CUMULATIVE INTEREST ANNUAL INCOME SCHEME
Scheme (p.a.) (Compounded Annually)
1 --- 11%
2 --- 11.5%
3 12.5% 12%
4 12.5% 12%
5 12.5% 12%
Deposit under the cumulative scheme is accepted for a period of 3 to 5 years only. Write a
program in Java ti find the:
(i) amount (A) due for sum (P) invested under the cumulative option scheme, by using
the formula A = P * [1 + (0.01 * r)]t
5
(ii) interest (I) for each year under the annual interest scheme, using the formula
I = 0.01 * P * r * t.
31. Write a program to accept length and breadth of a rectangle. Calculate and display the area,
perimeter or diagonal of the rectangle as per user’s choice.
32. Write an menu driven program to find the area of an Equilateral triangle, an isosceles triangle
and a scalene triangle as per User’s choice.
1. Equilateral Triangle =√3/4 8 s2, s = side of an equilateral triangle
2. Isosceles Triangle = ¼ * b * √4a2 – b2, a = equal sides of a triangle, b = base
3. Scalene triangle = √s * √s(s-a)(s-b)s-c) where s=( a + b + c)/2, a, b, c are three sides of
a triangle.
33. Write a menu driven program to find the sum, difference and product of two numbers. Perform
the tasks accordingly. Enter ‘+’ to find sum, ‘-’ to find the difference and ‘*’ to find the product of
two numbers.
34. Using switch case statement, write a menu driven program to convert a given temperat ure from
Fahrenheit to Celsius and vice versa. For an incorrect choice an appropriate error message
should be displayed. [C = 5.0/9.0 (F – 32) and F = 1.8 * c + 32]
35. Write a menu driven program to calculate the following:
1. Area of a circle = PI * r2 (PI=22.0/7.0)
2. Area of a square = side * side
3. Area of a rectangle = length * breadth.
36. Write a menu driven program to calculate the following:
1. Volume of a cube = side * side * side
2. Volume of a sphere = 4.0/3.0 * PI * radius * radius * radius (PI=22.0/7.0)
3. Volume of a Cuboid = length * breadth * height.
37. Write a menu driven program to perform either of the following conversions depending on the
user’s choice:
(i) KM to CM
(ii) Hours to Minutes
(iii)Centigrade to Fahrenheit
Programs using for Loop Statements
1. Write a program to find the sum of the even & odd numbers from 1 to 100.
2. Write a program to accept 10 different numbers and display the greatest and the smallest of
the numbers.
3. Write a program to print first 50 numbers of Fibonacci series.
4. Write a program to print the mathematical table of any given number.
5. The production (P) of crude oil of a country in millions of barrels may be estimated by the
following set of equations, where t represents the time in years.
P = 5 + 3t. 0 ≤ t ≤ 3, P = 14 + (t – 5 /2)2, for t > 3.
Write a program in java to find the production for every year from t = 1 to 10 and print it.
6. Write a program to print the number of leap year till the current year.
Leap year condition is [if(y%400==0 || y%100!=0 && y%4==0)].
7. Write a program to display the value of ‘x’ and ‘fx’ if fx = (x2+1)/(x2 – 1) and x ranges from 0
to 2.5 in step of 0.5. Take the value of fx = 0 when x = 1.0.
8. The population of a country at the end of the year can be found out by multiplying the
population (P) at the beginning of the year by (1 + X/100) where X is the growth rate of the
population. Taking as input the population (P) at the beginning of the year 1999 and the
growth rate (X), write a program to find the population at the beginning of each year from
2000 to 2014.
9. Write a program to calculate and print the value of Y where Y equals to:
Y = (n6 + n4 + n2 + 10)/(n5 + n3 +n)
for n ranging from 10 to 100 in step 5.
10. Write a program to calculate and print the factorial value of any single digit number.
11. Write a program to print all the Pythagorean triplets between 1 and 50.
12. Write a program to accept a number and find the minimum prime digit of the number.
13. Write a program to compute and print all the prime numbers between 100 and 500.
14. Write a program to display all the set of 5 consecutive composite numbers between 1 and 100.
15. Write a program to calculate the sum of all 3 digit prime number.
16. Write a program to accept a number and check if it is Armstrong prime or not.
17. Write a program to display all the Armstrong number between 100 and 999 in ascending as well
as in descending order.
18. Write a program to calculate and print the HCF and LCM of any two numbers using for loop.
19. Write a program to accept two numbers and find their LCM without finding the HCF.
6
20. Write a program to compute the following of any given number:
1. All the factors of the number 2. All the even factors of the number
3. All the odd factors of the number 4. All the prime factors of the number
21. Write a program to find out the integer between 1 and 10000 that has the largest number of
divisors. Print out the maximum number of divisors and an integer that has that many divisors.
22. Write a program to check if the number is perfect or not.
23. Write a program to find and print all the perfect number between 1 and 100. [Perfect number is
the number, which equal to the sum of its factor other than the number itself. For example
6=1+2+3]
24. Write a program to check and list all the special number between 1 and 1000.
25. Write a program to display all the prime Fibonacci series between 1 an 1000.
26. Write a program to display following output:
1 2 3 4 5 1 1 1 1 1 1 2 3 4 5 1 2 3 4 5 5 5 5 5 9 9 9 9 9
1 2 3 4 5 2 2 2 2 2 2 3 4 5 6 5 6 7 8 5 4 4 4 4 9 7 7 7 7
1 2 3 4 5 3 3 3 3 3 3 4 5 6 7 9 10 11 12 5 4 3 3 3 9 7 5 5 5
1 2 3 4 5 4 4 4 4 4 4 5 6 7 8 13 14 15 16 5 4 3 2 2 9 7 5 3 3
1 2 3 4 5 5 5 5 5 5 5 6 7 8 9 17 18 19 20 5 4 3 2 1 9 7 5 3 1
27. Write a program to display following output:
1 1 1 2 3 4 5 11 1 2 3 4 5 6 7 5 5 5 5 5
1 2 2 2 1 2 3 4 12 22 1 2 3 4 5 4 4 4 4
1 2 3 3 3 3 1 2 3 13 23 33 1 2 3 3 3 3
1 2 3 4 4 4 4 4 1 2 14 24 34 44 1 2 2
1 2 3 4 5 55 5 5 5 1 15 25 35 45 55 1
1 1 2 3 4 5 15 14 13 12 11 1 3 5 7 9
3 1 6 7 8 9 10 9 8 7 3 5 7 9 1
5 3 1 10 11 12 6 5 4 5 7 9 1 3
7 5 3 1 13 14 3 2 7 9 1 3 5
9 7 5 3 1 15 1 9 7 5 3 1
28. Write a program to display following output:
1 1 1 5 4 3 2 1
1 2 1 12 2 4 5 4 3 2
1 2 6 1 12 123 3 6 9 5 4 3
1 2 6 24 1 12 123 1234 4 8 12 16 5 4
1 2 6 24 120 1 12 123 1234 12345 5 10 15 20 25 5
29. Write a program to display following output:
1 5 1 1 2 3 4 5 6 1 1
2 1 4 5 2 2 1 1 1 1 1 2 3 1 2 1
3 2 1 3 4 5 3 3 3 1 1 1 2 3 4 5 1 2 3 2 1
4 3 2 1 2 3 4 5 4 4 4 4 1 2 3 4 5 6 7 1 2 1
5 4 3 2 1 1 2 3 4 5 5 5 5 5 5 1
30. Write a program to display following output:
0 0 0 0 1 1 0 1 0 1 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1
0 0 0 1 0 0 1 0 1 0 2 2 2 1 3 1 2 2 2 1 1 2 2 2 1 0 1 0 1 0
0 0 1 0 0 1 0 1 0 1 2 2 1 3 3 1 2 2 2 1 1 2 3 2 1 0 0 1 0 0
0 1 0 0 0 0 1 0 1 0 2 1 3 3 3 1 2 2 2 1 1 2 2 2 1 0 1 0 1 0
1 0 0 0 0 1 0 1 0 1 1 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1
1 1 0 1 0 1 1 0 0 0 0 * * * * $
1 0 1 0 1 0 0 1 0 0 0 * * * $ *
1 0 1 1 0 1 0 0 1 0 0 * * $ * *
1 0 1 0 1 0 0 0 0 1 0 * $ * * *
1 0 1 0 1 1 0 0 0 0 1 $ * * * *
31. Write a program to display following output:
1 1 `567898765 97531 25 1 1 1234554321
232 121 4567654 7531 16 13 4 1234 4321
34543 12321 34543 531 09 135 9 123 321
4567654 1234321 232 31 04 1357 16 12 21
567898765 123454321 1 1 01 13579 25 1 1
32. 1 22 333 4444 55555
33. 2 5 10 17 26 ….. 10th
34. 1 12 123 1234 12345
7
35. 1 11 111 1111 11111
36. 0 3 8 15 24 35 48 63 80 99 [2011]
37. 1 3 7 15 31 63 127 255 511 1023
38. Write a program to calculate the sum of following series:
1. S = 1*2 + 2*3 + 3*4 + 4*5 ………….+(19*20).
2. S = 1 + (1+2) + (1+2+3) + (1+2+3+4) + ……….. +(1+2+ ….. +n)
3. P = 1 * (1+2) * (1+2+3) * (1+2+3+4) * ……….. *(1+2+ ….. +n)
4. S = 1 + 1/3 +1/5 + 1/7 + …… + 1/n
5. S = 1 + 3 + 5 + 7 + ……. + n
6. S = +1-2+3-4+5-6+ ………. + n
7. S = 2 + 4 + 6 + 8 + ……. + n
8. S = 2 + 5 + 10 + 17 + 26 + ………10th term
9. S = 1*2*3*4 + 2*3*4*5 + 3*4*5*6 + ……. + 7*8*9*10
10. S = 12 + 22 + 32 + 42 + …… +252
11. S = 1 + 4 + 9 + 16 + 25 + ……… + nth terms
12. S = 1/1! + (1+2)/2! + (1+2+3)/3! + (1+2+3+4)/4! + ------+(1+2+3+----+N)/N!
13. S= 1 + 3 + 7 + 15 + 31 +- - - - - -+ nth terms
14. S = 0.5 +0.05 +0.005 + 0.0005 + - - - - - -+8th term.
15. S = x1/1! + x2/2! + x3/3! + x4/4! + .- -- --- + xn/n!.
16. S = 1 + 1/(1+2) + 1/(1+2+3) + 1/(1+2+3+4) + -- - - - +1/(1+2+3+ - - - - +n)
17. S = 1+a/2+a2/3+a3/4+---------------+an-1/n Where a and n is given as input.
18. S = 1+a/2!+a2/3!+a3/4!+---------------+a10/11! Where a is given as input.
19. S = 1- a/2! + a 2/3! – a3/4!+---------------+a19/20! Where a is given as input.
20. S = ¼+1/8+1/12+ ..... up to n terms.
21. S = 1/1! – 2/2! + 3/3! – 4/4! ........up to n terms.
22. S = x2/2! + x5/4! + x8/8! .... up to n terms.
23. S = 1! + 2! + 3! + 4! + . . . . . . . . +n!
24. S = (24 * 1) + (21 * 2) + (18 * 3) + (15 * 4) + . . . . . . . . up to n terms.
25. S = 1! +2! +3! + 4! + . . . . . . . . . . . to n terms
26. S = ½ + 2/3 + ¾ + 4/5 + . . . . . . . . to n terms
27. S = 9 + 99 + 8 + 89 + 7 + 79 + . . . . . . . to n terms
Programs using while and do while Loop Statements
1. Write a program to print the 52nd term of the Fibonacci series.
2. Write a program to print the Fibonacci series below 750.
3. Write a program to accept a number and check whether the number is present in the Fibonacci
series or not.
4. Write a program to input any number and out following results:
i. Print the digits in reverse order. iii. Product of the individual digits
ii. Sum of the individual digits iv. Arrange the digits in descending and ascending order
v. Find the Smallest Digit vi. Find the biggest digit
5. Write a program to accept a number and display the frequency of each digit present in the
number.
6. Write a program to input any five digit number and form the biggest number using the digits of
the number given as input. [Example: Input number – 67539 program output should be 97653]
7. Write a program to input any five digit number and form the biggest number using the digits of
the number given as input. [Example: Input number – 67539 program output should be 35679
OR Input Number 50143 Output should be 10345]
8. Write a program to check if the given number is a palindrome number or not.
9. Write a program to input any number and generate a palindrome number using the number given
as input.
10. Write a program to accept a number and find out the sum of the squares of the digits of the
number.
11. Write a program in java to calculate the fare for passengers travelling on a computerized bus. As
a passenger enters the bus, the computer displays “What distance will you travel?” On entering
the distance, the fare is displayed on the screen according to the following table:
Distance Fare
Up to 15 KM Rs. 5.00
Up to 25 KM Rs. 10.00
Above 25 KM Rs. 15.00
The computer keeps on adding and displaying the total fare after each passenger has entered the
distance and the program ends when the distance entered as “0”. It then displays the total
number of passengers who entered the bus and the total fare collected.
8
12. Write a program to display first 50 prime numbers from a given number.
13. A prime number is said to be “Twisted Prime”, if the new number obtained after reversing the
digits is also a prime number. Write a program to accept a number and check whether the
number is “Twisted Prime” or not.
14. Write a program to accept any number and find the sum of its prime digits.
15. Write a program to accept a number and check if it is prime number or not.
16. Write a program to accept a number and check if it is automorphic number or not.
17. Write a program to display all the automorphic numbers between 1 and 10000.
18. Write a program to calculate and print the HCF and LCM of any two numbers using division
method.
19. Write a program to check if the number is special or not. [A number is equal to the sum of the
factorial of each digit] [2011]
20. Write a program to input a number and check if the number is magic number or not.
21. Write a program to calculate and print the Binary equivalent of any number.
22. Write a program to calculate and print the Decimal equivalent of any binary number.
23. Write a program to convert a given decimal number to octal number.
24. Write a program to calculate and print the Decimal equivalent of any octal number.
25. Write a program to enter a number and check whether the number is neon number or not. A
number is said to be “Neon”, if the sum of the digits of the square of a number is equal to
number itself.
26. Write a program to accept a number and check whether the number is Unique or not. A number
is said to be unique if digits of a number are not repeated.
27. Write a program to accept a number and check whether the number is a Duck number or not. A
number is said to be Duck if the digit zero is present in it.
28. Write a program to accept a number and display the new number after removing all zeros.
29. Write a program to accept two numbers M and N consisting of two digits each and use Russian
Peasants method to find the product of M and N. The logic of the method is explained below with
a example. M N P
17 20 20
8 40 20
4 80 20
2 160 20
1 320 340
0 program stops and displays value of P
Program using Constructors and Constructor overloading:
1. Write class Students definition with the following members:
Data Members: Roll No., Height, Weight.
Member Functions/Methods: get( ) to accept data as parameters and initialize
data members
set ( ) to increase the height in field height based
on the parameter.
print ( ) to display the data.
2. Write class definition with the following members:
Data Members: Roll No., Height, Weight.
Member Methods: constructor function to initialize data members
by default value of height as 5.5 feet and weight as 50 Kg
display ( ) to display the data.
3. Write a java class Time with the following specifications:
Data Members Member functions
Hour default constructor to initialize time
Minutes parameterized constructor: initialize time
Seconds show( ) : display time
reset ( ) : reset time
4. Write a java class Date and define a constructor for the class for the following specification.
Data Members Member functions
Day (dd) default constructor to initialize date
Month (mm) parameterized constructor to initialize date of birth
Year (yy) yearPlus( ) : to increase the year of date by 1
display( ) : display date.
5. Define a class student having the following description:
Data members/Instance variable:
String name : to store the name of the student.
9
int roll : to store the roll number of the student.
int p,c,b : to store his physics, chemistry and biology marks
double S : to store his science marks (average of physics, chemistry
and biology)
Member function:
input () : to input the details.
calculate () : to calculate the science marks.
display () : to display the details in following format:
Name Roll No. Science Marks
Also write the main method to create an object and call the above methods.
6. Design a class using proper constructors to represent a bank account. Including the following
members.
Data Members Member functions
Name of the depositor Parameterized constructor to assign initial value
Account Number To deposit an amount
Type of Account To withdraw an amount after checking the
balance
Balance amount in the account To display the name and balance
7. Define a class Pay in java with following specification:
Data Members Member functions
String name, address *Pay(String n, String add, String cy, Float s)-
& city *Parameterized constructor to initialize the data members.
double salary, da, hra, *void outputData( )-to display initial values
pf, gs, ns *void calculate( ) – to calculate following details:
da = 15% of salary
hra = 10% of salary
pf = 12% of salary
gs = salary + da + hra
ns = gs – pf
*void display( ) – to display the complete information
Program using Function, Function overloading
1. Define a class with following functions:
1. circle(pie * r2 ) where pie = 3.14 to find the area of circle
2. Square (side * side) to find the area of square
3. Rectangle (length * breath) to find the area of a rectangle
2. Define a class to overload a function area( ) as follows:
1. void area (double r) to compute the area of a circle where pie = 3.14
2. void area (int s) to compute the area of a square
3. void area (int l, int b) to compute area of a rectangle.
3. Define a class to overload a function number ( ) as follow:
1. void greatest (int a, int b, int c) to display the greatest.
2. void greatest (double a, double b, double c) to display the greatest
3. void greatest ( int a, double b, double c) to display the greatest
String handling programs to practice
1. Write a program to display the number of vowels found in any given string.
2. Write a program to accept a sentence and find out the percentage of vowels in that sentence.
3. Write a program to accept a sentence and find out the number of vowels and the number of
consonants in the sentence.
4. Write a program to accept a word and display the new sword after removing the vowels present
in the word. Example: COMPUTER APPLICATION --> CMPTR PPLCTNS
5. Write a program to accept a string in uppercase and find the frequency of each vowel present in
the string.
6. Write a program to print the given word in reverse.
7. Write a program to display the number of words and blank space in any given sentence.
8. Write a program in Java to accept a sentence and find the average number of alphabets present
in each word of the sentence.
9. Write a program to accept a sentence and reverse it word by word. For example, if the input is
THIS DOON SCHOOL the output should be SCHOOL DOON IS THIS.
10. Write a program to display each word in reverse of any given string.
11. Write a program to print the frequency of all the characters within a string.
12. Write a program to print the alphabets of any given word in alphabetic order.
13. Write a program to find and print the longest and the shortest word in any given string.
10
14. Write a program to count the number of upper case and lower case alphabets in a string.
15. Write a program to count the number of alphabets, special characters and digits in any given
sentence.
16. Write a program to convert first letter of each word to upper case.
17. Write a program to check if the given word is palindrome or not.
18. Write a program to compute the sum of ASCII codes of the vowel present in any string.
19. Write a program to accept a sentence and display all the words in separate lines along with their
length.
20. Write a program to accept a sentence having letters in upper case and lower case. Display the
sentence after change the upper case letters to lower case and vice versa. For example:- Input
– He is a Bad Boy. Output – hE IS A bAD bOY.
21. Write a program having replaceWord ( ) function, which take three parameters, one, the
sentence, two, the word to be replaced, third, the new word. Print the sentence with new word in
it. For example: “Today is my practical class” output – “Today is my theory class”
22. Write a program having deleteWord ( ) function, which take two parameters, one, the sentence,
two, the word to be deleted. Prints the modified sentence. For example: “I will never come to
your house” output – “I will come to your house”.
23. Write a program to accept a sentence and print only the first letter of each word of the sentence
in capital letters separated by a full stop.
Example: INPUT Sentence: “Come let us bat” OUTPUT: C.L.U.B.
24. Write a program to print your name in abbreviated form. For example: Subhash Chandra Bose
Output – S. C. Bose.
25. Write a program to print your name in abbreviated form. For example: Subhash Chandra Bose
Output –Bose, S. C.
26. Write a program to print your name and print the surname first and then the name, separated by
comma. For example: Subhash Chandra Bose Output –Bose, Subhash Chandra.
27. Write a program to count number of digits present in a sentence, if no digits are found display
appropriate message.
28. Write a program to display following string formats:
c computer c ABCDEFGHHGFEDCBA R
co compute c o ABCDEFGHHGFEDCBA ER
com comput c o m ABCDEFGHHGFEDCBA TER
comp compu c o m p ABCDEFGHHGFEDCBA UTER
compu comp c o m p u ABCDEFGHHGFEDCBA PUTER
comput com c o m p u t ABCDEFGHHGFEDCBA MOUTER
compute co c o m p u t e ABCDEFGHHGFEDCBA OMPUTER
computer c c o m p u t e r ABCDEFGHHGFEDC A COMPUTER
29. Write a program to display following string formats:
a A a u t s r q p * U BLUEJ
b c b C b c o n m l k P * U P U T LUEJB
d e f d E f d e f j i h g M P * U T M P U T E UEJBL
g h i j G h I j g h i j f e d O M P * U T E O M P U T E R EJBLU
k l m n o K l M n O k l m n o b c C O M P * U T E R C O M P U T E R S JBLUE
p q r s t u p Q r S t U p q r s t u a
30. Write a program to store “DONBOSCO” in an appropriate variable and generate the following
output
D
D O
D O N
D O N B
D O N B O
D O N B O S
D O N B O S C
D O N B O S C O
31. Program which replaces each character in s by the character which is at a distance of move
ahead, if move is positive. If move is 0 the original string is returned unchanged. If move is
negative, then each character is replaced by a character at a distance move behind it. For
example:
When s=”ABCXYZ”, encodeDecode (2) returns “CDEZAB” and
When s=”ABCDE”, encodeDecode (-3) returns “XYZAB”
32. Program to input a sentence and display words that are starting with vowel.
11
33. Write a program to accept a word and generate a PIG LATIN word. [Example – Word – KING
output – INGKAY or TROUBLE output OUBLETRAY]
34. Write a program to accept a String and display only those characters which are consecutive:
Sample Input: UNDERSTANDING COMPUTER APPLICATIONS
Sample output: D, E
R, S
S, T are consecutive characters.
35. Write a program to accept a String and count how many times a Alphabet is used repeatedly:
Sample Input: Application of scanner class in java programme
Sample output: 4
36. Write a program to input your mane and display your name with all the vowels in uppercase and
others in lowercase.
37. Write a program to input two strings and check if they are anagram or not. Two strings are said
to be anagram if the same alphabets of one string is used in the second string. For example
SCHOOL MASTER AND THE CLASS ROOM.
38. Write a program to accept a word and display ASCII value of each character.
39. Write a program to accept a word and display the new word after removing all the repeated
alphabets.
40. Write a program to accept a string and check whether the string is Unique or not. A string is said
to be Unique if none of the alphabets in the string are repeated.
Array handling programs
1. Write a program to input 10 values into an array and display the square of each element of the
array.
2. Write a program to store 15 values in Array A and add 5 to each element and store it in Array
B.
3. Write a program to store 20 values in an array and display the array in reverse order.
4. Write a program to store 10 values in two arrays X and Y and check if they are identical or not.
5. Write a program to find the largest and the smallest number in an array.
6. Suppose A, B, and C is arrays of integers of sizes m, n, and m + n respectively. Write a
program to produce a third array C, containing all the data of array A and B.
7. Write a program to check whether or not two arrays (of characters) are identical, that is,
whether they have same characters and all characters in corresponding positions are equal.
8. Write a program using array to find the ASCII code of the following characters: A, B, 8, <, AND
!.
9. Write a program to print the given number in words. For example if the given number is
124356 then in should output “one lakh twenty four thousand three hundred fifty six”.
10. Write a program using arrays that stores the name, English Marks, Math Marks and Science
Marks for 40 students. The program should calculate the total marks and percentage of each
students and the average marks obtained by the class in each subject.
11. Write a program to store 15 19 25 36 48 59 67 72 83 99 in an array and perform Binary Search
in an array for a number given as input.
12. Write a program to store 15 12 62 54 32 86 72 55 43 91 in an array and perform Linear Search
in a given array for a number given as input.
13. Write a program to store 15 19 25 36 48 59 67 72 83 99 in an array and Sort the array using
Bubble Sort Method.
14. Write a program to store 15 19 25 36 48 59 67 72 83 99 in an array and Sort the array using
Selection Sort Method.
15. The names and Computer Application marks of 80 students are to be stored in arrays N[x] and
M[x]. Write a program to store the data and also arrange the data in alphabetical order of
names using Bubble sort method.
16. Write a program to store 15 numbers in an array and delete the element from a position chosen
by the user. Display both original and the modified array.
17. Write a program to store 15 numbers in an array and insert one element at the position chosen
by the user. Display both original and the modified array.
18. Write a program to store the names of the ten cricket players, number of innings played, and
runs scored. Input any one players name and search the array and display the number of
innings played and runs scored by him.
19. Write a program to take a sentence having repeated words in it. Display each word and the
frequency of that word in the sentence.
20. Write a program to store Roll numbers, names and marks of 10 students. Display the list in
descending order of marks.
21. Write a program to lexicographically arrange the ten words stored in an array.
12
22. Write a program to store 20 different names in Single Dimensional array and display only those
name which begin with a vowel.
23. Write a program to delete duplicate (repeated twice only) elements from a single dimensional
array of characters. Display the array with unique elements.
24. Write a program to display Pascal’s triangle as shown below:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
25. Write a program to store 10 words in an array and display the words in descending order of
their length.
26. Write a program where two single dimensional array each of size [10], one having names of the
state and other having their state capitals. Input any state name and display its capital and if
the state does not exists, give appropriate message. Program should continue to work till the
user wants it to run.
27. Write a program to store data 5, -7, 3, -4, -6, 2, 9, -8, 1 in an array and arrange the array by
keeping the positive number on left side and negative number on right side without changing
the sequence in the original array (without another array)as show here 5, 3, 2, 9, 1, -7, -4, -6,
-8
Programs using BufferedReader class (using keyboard to input values during execution)
1. Write a program to accept a five digit integer from keyboard and output the following:
a. The message ‘Invalid Data’ has to be printed for the following cases:
1. If the number of digits is less than 5 or greater than 5.
2. If any of the digits is zero.
b. If the number is found to be valid then find:
1. The absolute difference between first an last digit.
2. The absolute difference between the original number and the number obtained
by reversing the digits
2. Write a program to input temperature of 12 months from the keyboard. Compute and display
the average temperature and the maximum temperature.
3. Write a program to input a value from the keyboard and generate a palindrome number from it.
Display the number and the palindrome number.
4. Write a program to print the sum of negative numbers, sum of positive even numbers and sum
of positive odd numbers from a list of numbers entered by the user from the keyboard. The list
terminates when the user enters a zero.
ICSE questions [2005]
1. Write a class with employee name and basic pay as its data member. Compute and display the
net pay of the employee based on following allowances and deductions: Use meaningful
variables. Dearness Allowance (DA) 25% of Basic Pay
House Rent Allowance (HRA) 15% of Basic Pay
Provident Fund (PF) 10% of Basic Pay
Gross Pay(GP) = Basic Pay + DA + HRA
Net Pay = GP– PF
2. Write a program to input any given string to calculate the total number of characters and
vowels present in the string and also reverse the string: Example: Input Enter String:
SNOWY
OUPUT: Total Number of Characters : 5
Number of vowels : 1
Reverse String : YWONS
3. Write a program using a function called area() to compute the area of a:
i) circle ii) Square iii) rectangle
Display the menu to output the area as per User’s choice.
4. Write a program to bubble sort the following set of values in ascending order.
5, 3, 8, 4, 2, 9, 1, 12, 98, 16
5. Write as program to print the sum of negative numbers, sum of positive even numbers, and
sum of positive odd numbers from a list of number entered by the user. The list terminates
when the user enters a zero.
6. Write a program to initialize an array of 5 names and initialize another array with their
respective telephone numbers. Search for a name input by the user in the list. If found display
13
“Search Successful” and print the name along with the telephone number, otherwise “Search
Unsuccessful, name not enlisted”.
ICSE questions [2006]
1. A cloth showroom has announced the following festival discounts on the purchase of items,
based on the total cost of the item purchased:-
Total Cost Discount (in %)
Less than Rs. 2000 5%
Rs.2000 to Rs.5000 25%
Rs.5001 to Rs.10000 35%
Above Rs.10000 50%
Write a program to input the total cost and to compute and display the amount to be paid by
the customer after availing the discount.
2. Write a program to output the result of the following based on the number entered by the User.
i. Natural logarithm of the number ii. Absolute value of the number
iii. Square root of the number iv. Random number between 0 and 1
3. The Marks obtained by 50 students in a subject is tabulated as follows:
Name Marks
Write a program to input the names and marks of the students in the subjects and calculate
and display: 1. The subject average marks
2. The highest marks in the subject and name of the student.
(The maximum marks in the subject are 100)
4. Write a program to initialize a string with “January 26 is celebrated as the Republic Day of
India” and change the sentence to “August 15 is celebrate as the Independence Day of India”.
5. Write a program to calculate and print the sum of odd numbers and the sum of even numbers
for the n natural number. The integer n is to be entered by the User.
6. Write a program to accept 15 integers from the keyboard, assuming that no integer entered is
zero. Perform selection sort on the integer and then print them in ascending order.
ICSE questions [2007]
1. Define a class Salary as per the details given below:
Data Members : Name, Address, Phone, Subject Specialisation, Monthly salary, Income
Tax.
Member Methods : 1. to accept the details of the teacher including monthly salary
2.To compute annual income tax at 5% of the annual salary above
Rs.1,75,000/-
3.To display the details of the teacher
2. Write a program to compute and display the sum of the following series:
1 + 2 1+2+3 1+2+3+4 1+2+3+4+ -------+n
------ + -------- + ----------- + -----------------------
1 * 2 1*2*3 1*2*3*4 1*2*3*4*--------*n
3. Write a program to initialize the given data in an array and find the minimum and maximum
value along with the sum of the given elements
Numbers : 2 5 4 1 3 Output : Minimum Value : 1
Maximum Value : 5
Sum of the elements : 15
4. Write a program to enter a sentence from the keyboard and count the number of times a
particular word occurs in it. Display the frequency of the search word.
5. Using switch case 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.]
6. Write a program using a method Palin( ) to check whether a string is a Palindrome or not. A
Palindrome is a string that reads the same from left to right and vice versa.
ICSE questions [2008]
1. Define a class Employee having the following description:
Data Member/Instance Variable: int panto store personal account number
String name to store name
double taxincome to store annual taxable income
double tax to store that is calculated
Member functions/Methods : input( )store the PAN number, name and taxable income
+
14
calc( ) Calculate tax for an employee
display( ) output details of an employee.
Write a program to compute the tax according to the given conditions and display the output
as per given format.
Total Annual Taxable Income Tax Rate
Up to Rs.1,00,000 No Tax
From Rs.1,00,001 to 1,50,000 10% of the income exceeding Rs.1,00,000
From Rs.1,50,001 to 2,50,000 Rs.5,000 + 20% of the income exceeding 1,50,000
Above Rs.2,50,000 Rs.25,000 + 30% of the income exceeding 2,50,000
Output: PAN Number Name Tax-income Tax
2. Write a program to input a string and print out the text with the uppercase and lowercase
letters reversed, but all other character should remain the same as below:
Example : INPUT : WelComE to School
OUTPUT : wELcOMe TO sCHOOL
3. Define a class and store the given city names in a single dimensional array. Sort these names
in alphabetical order using Bubble Sort technique only.
INPUT : Delhi, Bangalore, Agra, Mumbai, Calcutta
OUTPUT : Agra, Bangalore, Calcutta, Delhi, Mumbai
4. Write a menu driven class to accept from the user and check whether it is a Palindrome or a
Perfect number.
1.Palindrome Number: (a number is a Palindrome which when read in reverse
order is same as read in the right order. Example: 11, 101, 151 etc)
2.Perfect number : (a number is called perfect if it is equal to the sum of
its factors other than the number itself. Example : 6 = 1+2+3)
5. Write a class with the name Volume using function overloading that computes the volume of a
cube, a Sphere and a cuboids.
1. Volume of cube : vc = s * s * s;
2. Volume of sphere: vs = 4.0/3.0 * π * r * r * r; (where π = 3.14 or Math.PI)
3. Volume of cuboids : vcd = l * b * h
6. Write a program to calculate and print the sum of each of the following series:
1. Sum (S) = 2 – 4 + 6 – 8 + ---------- -20
2. Sum (S) = x/2 + x/5 + x/8 + x/11 + ----------- + x/20 (value of x to be input by user)
ICSE questions [2009]
1. An electronics shop has announced the following seasonal discounts on the purchase of
certain items.
Write a program based on above criteria, to input name, address, amount of purchase and the
type of purchase (L for laptop and D for Desktop) by a customer. Compute and print the net
amount to be paid by a customer along with his name and address. (HINT: discount =
(discount rate/100)*amount of purchase. Net Amount = amount of purchase – discount)
2. Write a program to generate triangle or an inverted triangle till n terms based upon the user’s
choice of the triangle to be displayed.
Input user’s choice: 1. Triangle 2. Inverted triangle
Input number of terms: If number of terms is 5 if choice is inverted triangle
OUTPUT: if choice is Triangle 1 5 5 5 5 5
2 2 4 4 4 4
3 3 3 3 3 3
4 4 4 4 2 2
5 5 5 5 5 1
3. Write a program to input a sentence and print the number of characters in the longest word of
the given sentence.
For Example if S = “India is my country” then the output should be 7
4. Design a class to overload a function num calc( ) as follows:
a. void num_calc(int num, char ch) with one integer argument and one character argument,
computes the square of integer argument if choice ch is ‘s’ otherwise finds its cube.
b. void num_calc(int a, int b, char ch) with one integer argument and one charact er
Purchase Amount in
Rs.
Discount on
Laptop
Discount on Desktop PC
00000 – 25000
25001 – 57000
57001 – 100000
More than 100000
0.0%
5.0%
7.5%
10.0%
5.0%
7.5%
10.0%
15.0%
15
argument, computes the product of integer argument if choice ch is ‘p’ otherwise adds the
integers.
c. void num_calc(String s1, String s2) with two String arguments, which prints whether the
strings are equal or not.
5. Write a menu driven program to accept a number from the user and check whether it is a
“BUZZ” number OR to accept any two numbers and print the ‘GCD’ of them.
1. A BUZZ number is the number which either end with 7 or divisible by 7.
2. GCD (Greatest Common Divisor) of two integers is calculated by continued division
method. Divide the larger number by the smaller number; the remainder then divides the
previous divisor. The process is repeated till the remainder is zero. The divisor then result the
GCD.
6. The annual examination result of 50 students in a class is tabulated as follow:
Roll No. Subject A Subject B Subject C
Write a program to read the data, calculate and display the following:
1. Average marks obtained by each student
2. Print the roll number and average marks of the students whose average mark is above 80.
3. Print roll numbers and average marks of the students whose average mark is below 40.
ICSE questions [2010]
1. Write a program to perform binary search on a list of integers given below, to search for an
element input by the user, if is fond display the element along with its position, otherwise
display the message “Search element not found” 5, 7, 9, 11, 15, 20, 30, 45, 89, 97
2. Define a class Student described as below:
Data members/instance variable:
name, age, m1, m2, m3 (marks in 3 subjects), maximum, average
Member Methods: (i) A parameterized constructor to initialize the data members
(ii) To accept the details of a student
(iii) To compute the average and the maximum out of three
marks
(iv) To display the name, age, marks in three subjects,
maximum and average.
Write a main method to create an object of a class and call the above member methods.
3. Shasha Travels Pvt. Ltd. Gives the following discount to its customers:
Ticket Amount Discount
Above Rs. 70000 18%
Rs.55001 to Rs.70000 16%
Rs.35001 to Rs.55000 12%
Rs.25001 to Rs.35000 10%
less than Rs.25001 2%
Write a program to input the name and ticket amount for the customer and calculate the
discount amount and net amount to be paid. Display the output in the following format for
each customer:
Sl. No. Name Ticket Charges Discount Net Amount
-------- ------- ----------- --------- ----------
-
(Assume that there are 15 customers, first customer is given the serial no. (Sl. No.) 1, next
customer 2 … and so on)
4. Write a menu driven program to accept a number and check and display whether it is prime or
not OR an automorphic number or not. (Use switch case statement)
(a) Prime Number: A number is said to be a prime number if it is divisible only by 1
and itself and not by any other number. Example: 3, 5, 7, 11, 13 etc.
(b) Automorphic Number: An Automorphic number is the number which is contained
in the last digit(s) of its square. Example: 25 is an automorphic number as its square is 625
and 25 is present as the last two digits.
5. Write a program to store 6 elements in a array P, and 4 element in an array Q and produce a
third array R, containing all the elements of array P and Q. Display the resultant array.
Example: INPUT in P[ ] 4 6 1 2 3 10 and in Q[ ]19 23 7 8
OUTPUT R[ ]  4 6 1 2 3 10 19 23 7 8
6. Write a program to input a string in uppercase and print the frequency of each character.
Example: INPUT COMPUTER HARDWARE
OUTPUT: CHARACTER FREQUENCY
A 2
16
C 1
D 1
E 2
H 1
M 1
O 1
P 1
R 3
T 1
U 1
W 1
ICSE Question [2011]
1. Define a class called Mo-bike with the following description:
Instance variable/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 - to calculate and store the rental charges
Member Methods:
void input() - to input and store details of the customer
void compute()- to compute the rental charges
The rent for the mo-bike is charges on the following basis:
First 5 days Rs.500 per day
Next 5 days Rs.400 per day
Rest of the days Rs.200 per day
void display() - to display the details in the following format:
Bike No Phone No. Name No. Of days Charge
-------- ----------- ------------- ------------- ----------
2. Write a program to input and store the weight of ten people. Sort and display them in
descending order using the selection sort technique.
3. Write a program to input a number and print whether the number is a special number or not.
4. Write a program to accept a word and convert it to lowercase if it is in uppercase and display
the new word by replacing only the vowels with the character following it.
Example: Sample input : computer
Sample output : cpmpvtfr
5. Design a class to overload a function compare ( ) as follows:
1. void compare ( int, int)- to compare two integer values and print the greater of the
two integers.
2. void compare (char, char)- to compare the numeric value of two characters and
print the character with higher numeric value.
3. void compare (String, String)- to compare the length of the two strings and print the
longer of the two.
6. Write a menu driven program to perform the following: (Use switch – case statement)
1. To print the series 0, 3, 8, 15, 24 .. n terms (value of ‘n’ is to be an input by the user).
2. To find the sum of the series given below:
S = ½ + ¾ + 5/6 + 7/8 + ............. + 19/20
ICSE Question [2012]
2. Define a class Called Library with the following description:
Instance variable/data members:
int acc_num - Stores the accession number of the book
String title - stores the title of the book
String Author - store the name of the author
Member methods:
i.Void input() -to input and store the accession number, title and author
ii.Void compute () -To accept the number of days late, calculate and display the fine
To be charged at Rs. 2 per day.
iii.Void display To display the details in the following format:
Accession Number Title Author
Write a main method to create an object of the class and call the above member methods.
17
2. Given below is a hypothetical table showing rates of Income Tax for male citizens below the
age of 65 years:
Taxable Income (TI) in Rs. Income Tax in Rs.
Does not exceed Rs. 1,60,000 Nil
Is greater than Rs.1,60,000 & less than or equal to
Rs.5,00,000
(TI – 1,60,000) x 10%
Is greater than Rs.5,00,000 & less than or equal to
Rs.8,00,000
[(TI – 5,00,000) x 20%] + 34,000
Is greater than Rs.8,00,000 [(TI – 8,00,000) x 30%] + 94,000
Write a program to input age, gender (male or female) and Taxable Income of a person.
If the age is more than 65 or the gender in female, display “wrong category”.
If the age is less than or equal to 65 years and the gender is male, compute and display the
Income Tax payable as per the table given above.
3. Write a program to accept a string. Convert the string to uppercase. Count and output the
number of double letter sequences that exist in the string.
4. Design a class to overload a function polygon () as follows:
i.Void polygon (int n, char ch)-with one integer argument and one character type
argument that draws a filled square of side n using the
character stored in ch.
ii.void polygon(int x, int y) -with two integer argument that draws a filled rectangle of
length x and breadth y, using the symbol ‘@’.
iii.void polygon () - with no argument that draws a filled triangle shown below
*
* *
* * *
5. Using switch case statement, write a menu driven program to:
i.Generate and display the first 10 terms of the Fibonacci series starting from 0.
ii.Find the sum of the digits of an integer that is input
For an incorrect choice an appropriate error message should be displayed.
6. Write a program to accept the names of 10 cities in a single dimension string array and their
STD codes in another single dimension integer array. Search for a name of a city input by the
user in the list. If found display “search successful” and print the name of the city along with
its STD code, or else display the message “Search Unsuccessful, No such city in the list”.
ICSE Question [2013]
1. Define a class named FruitJuice with following description:
Instance variable/data Members:
int product_code :Store the product code number
String flaour :Store the flaour of the juice (E.g. Orange,apple etc.)
String pack_type :Store the type of packaging (Eg. Tetra Pack, PET bottle etc.)
int pack_size :Store packagr size (Eg. 200ml, 400ml etc)
int product_price :Store the price of the product
Member Methods:
i. FruitJuice() :Default constructor to initialize integer data members to 0 and
String data members to “”.
ii. void input() :To input and store the product_code, flavour,pack_type,
pack_size and product_price.
iii. void discount() :to reduce the product_price by 10.
iv. void display() :to display the product code, flavour, pack size and product price.
2. The international Standard Book Number (ISBN) is a unique numeric book identifier which is
printed on every book. The ISBN is based upon a 10 digit code. The ISBN is legal if:
1*digit1 + 2*digit2 +3*digit3 + 4*digit4 + 5*digit5 + 6*digit6 +7*digit7 + 8*digit8 + 9*digit9 +
10*digit10 is divisible by 11.
Example: for a ISBN 1401601499
1*1+ 2*4 +3*0 + 4*1 + 5*6 + 6*0 +7*1 + 8*4 + 9*9 + 10*9=253 which is divisible by 11.
Write a program to:
(i) input the ISBN code as 10 digit integer.
(ii) If ISBN is not 10 digit integer, output the message, “Illegal ISBN and terminate the
program.
(iii) If the number is 10 digit do the calculation as shown above.
(iv) If sum is divisible by 11, output message, “Legal ISBN”. If the sum is not divisible by 11
output the message “Illegal ISBN”.
18
3. Write a program that encodes a word into Pig latin. To translate a word into a Pig latin word,
convert the word to Uppercase and then place the first vowel of the original word as the start
of the new word along with the remaining alphabets. The alphabets present before the vowel
being shifted towards the end followed by “AY”.
Sample input (1) : London Output – ONDONLAY
Sample input (2) : Olympics Output – OLYMPICSAY
4. Write a program to input 10 integer element in an array and sort them in descending order
using the bubble sort technique.
5. Design a class to overload a function series() as follows:
(i) double series(double n) with one double argument and returns the sum of the series,
sum = 1/1+1/2+1/3+......+1/n
(ii) double series(double a, double n) with two double arguments and returns the sum of t he
series, sum = 1/a2+4/a5+7/a8+10/a11+ .......to n terms.
6. Using switch statement, write a menu driven program:
(i) To check and display whether a number input by the user is a composite number or not
(A number is said to be a composite, if it has one or more than one factor
excluding 1 and the number itself. Example 4, 6, 8, 9 . . . . . . .
(ii) To find the smallest digit of an integer that is input.
Sample input : 6524
Sample output : Smallest digit is 2
For an incorrect choice, an appropriate error message should be displayed.
ICSE Question [2014]
Q 1: Define a class named movieMagic with the following desctription:
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 popularity rating of the movie
(minimum rating = 0.0 and maximum rating = 5.0)
Member methods:
movieMagic() : default constructor to initialize numeric data members to o
and String data members to “”.
void accept() : to input and store year, title and rating.
void display() : To display the title of the movie and the 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-hits
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
method.
Q 2: A special two digit number is such that when the sum of its digits is added to the
product of its digits, the result is equal to the original two digit number. Write a
program to accept a two digit number. Add the sum of its digits to the product of its
digits. If the value is equal to the number input, out the message “Special 2 digit
number” otherwise output the message “Not a special 2 digit number”.
Q 3: Write a program to assign a full path and file name as given below. Using library
function extract and out put the file path, file name and file extension separately as
shown: Input : C:UsersadminPicturesflower.jpg
Output : Path: C:UsersadminPictures
File name: flower
Extension: jpg
Q 4: Design a class to overload a function area() as follows:
(i) double area(double a, double b, double c) with three arguments, returns the
area of a scalene triangle using the formula:
area = √s(s-a)(s-b)(s-c) where s = (a+b+c)/2
(ii) double area (int a, int b, int height) with three integer arguments, returns the
area of a trapezium using the formula:
area = ½ height(a+b)
(iii) double area(double diagonal1, double diagonal2) with two double arguments,
returns the area of a rhombus using the formula:
19
area = ½ (diagonal1 x diagonal2)
Q 5: Using switch statement, write a menu driven program to calculate the maturity amount
of a Bank Deposit. The user is given the following option:
(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 x n x P x n(n+1)/2 x r/100 x 1/12
For an incorrect option, an appropriate error message should be displayed.
Q 6: Write a program to accept the year of graduation from school as an integer value from
the user. Using Binary Search technique on the sorted array of integers given below,
output the message “Record exists” if the value input is located in the array. If not,
output the message “Record does not exist”.
{1982, 1987, 1993, 1996, 1999, 2003, 2006, 2007, 2009, 2010}

More Related Content

What's hot

Number System
Number SystemNumber System
Number Systemitutor
 
27 tally presentation
27 tally presentation27 tally presentation
27 tally presentationManoj Bhatla
 
Binary to Decimal Conversion
Binary to Decimal ConversionBinary to Decimal Conversion
Binary to Decimal ConversionMac Mac
 
Account for Non Profit Organization
Account for Non Profit OrganizationAccount for Non Profit Organization
Account for Non Profit OrganizationDHRUBASETHI
 
Computer science Project for class 11th and 12th(library management system)
Computer science Project for class 11th and 12th(library management system)Computer science Project for class 11th and 12th(library management system)
Computer science Project for class 11th and 12th(library management system)lokesh meena
 
Computer number systems
Computer number systemsComputer number systems
Computer number systemsRevi Shahini
 
Chemistry project part 1 caseins in milk......
Chemistry project part 1 caseins in milk......Chemistry project part 1 caseins in milk......
Chemistry project part 1 caseins in milk......AnuragSharma530
 
CLASS IX MATHS Coordinate geometry ppt
CLASS IX MATHS Coordinate geometry pptCLASS IX MATHS Coordinate geometry ppt
CLASS IX MATHS Coordinate geometry pptRc Os
 
Fibonacci series and Golden ratio
Fibonacci  series and Golden ratioFibonacci  series and Golden ratio
Fibonacci series and Golden ratioMuhammad Ukasha
 
Number system.pdf
Number system.pdfNumber system.pdf
Number system.pdfDeepuGuna
 
Class 11 important questions for physics Scalars and Vectors
Class 11 important questions for physics Scalars and VectorsClass 11 important questions for physics Scalars and Vectors
Class 11 important questions for physics Scalars and VectorsInfomatica Academy
 
Scientific notation presentation
Scientific notation presentationScientific notation presentation
Scientific notation presentationlothomas
 

What's hot (20)

Computer Number System
Computer Number SystemComputer Number System
Computer Number System
 
01.Number Systems
01.Number Systems01.Number Systems
01.Number Systems
 
Number System
Number SystemNumber System
Number System
 
Scientific Notation
Scientific NotationScientific Notation
Scientific Notation
 
27 tally presentation
27 tally presentation27 tally presentation
27 tally presentation
 
Binary to Decimal Conversion
Binary to Decimal ConversionBinary to Decimal Conversion
Binary to Decimal Conversion
 
Account for Non Profit Organization
Account for Non Profit OrganizationAccount for Non Profit Organization
Account for Non Profit Organization
 
Computer science Project for class 11th and 12th(library management system)
Computer science Project for class 11th and 12th(library management system)Computer science Project for class 11th and 12th(library management system)
Computer science Project for class 11th and 12th(library management system)
 
Conversion of number system
Conversion of number systemConversion of number system
Conversion of number system
 
Conversion binary to decimal
Conversion binary to decimalConversion binary to decimal
Conversion binary to decimal
 
Computer number systems
Computer number systemsComputer number systems
Computer number systems
 
Chemistry project part 1 caseins in milk......
Chemistry project part 1 caseins in milk......Chemistry project part 1 caseins in milk......
Chemistry project part 1 caseins in milk......
 
CLASS IX MATHS Coordinate geometry ppt
CLASS IX MATHS Coordinate geometry pptCLASS IX MATHS Coordinate geometry ppt
CLASS IX MATHS Coordinate geometry ppt
 
Fibonacci series and Golden ratio
Fibonacci  series and Golden ratioFibonacci  series and Golden ratio
Fibonacci series and Golden ratio
 
Number system conversion
Number system conversionNumber system conversion
Number system conversion
 
Number system
Number systemNumber system
Number system
 
Number system.pdf
Number system.pdfNumber system.pdf
Number system.pdf
 
Class 11 important questions for physics Scalars and Vectors
Class 11 important questions for physics Scalars and VectorsClass 11 important questions for physics Scalars and Vectors
Class 11 important questions for physics Scalars and Vectors
 
Integers
IntegersIntegers
Integers
 
Scientific notation presentation
Scientific notation presentationScientific notation presentation
Scientific notation presentation
 

Similar to List of programs to practice for ICSE

Comp 122 lab 2 lab report and source code
Comp 122 lab 2 lab report and source codeComp 122 lab 2 lab report and source code
Comp 122 lab 2 lab report and source codepradesigali1
 
1 University of Leeds School of Computing Proced.docx
1 University of Leeds       School of Computing Proced.docx1 University of Leeds       School of Computing Proced.docx
1 University of Leeds School of Computing Proced.docxjeremylockett77
 
Part I (Short Answer)1. In Java, what are the three different w.docx
Part I (Short Answer)1. In Java, what are the three different w.docxPart I (Short Answer)1. In Java, what are the three different w.docx
Part I (Short Answer)1. In Java, what are the three different w.docxherbertwilson5999
 
Comp 122 lab 3 lab report and source code
Comp 122 lab 3 lab report and source codeComp 122 lab 3 lab report and source code
Comp 122 lab 3 lab report and source codepradesigali1
 
COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEWshyamuopeight
 
Topic 2 Cf And Making Investment Decisions
Topic 2 Cf And Making Investment DecisionsTopic 2 Cf And Making Investment Decisions
Topic 2 Cf And Making Investment Decisionsshengvn
 
NCV 4 Mathematical Literacy Hands-On Support Slide Show - Module 3 Part 1
NCV 4 Mathematical Literacy Hands-On Support Slide Show - Module 3 Part 1NCV 4 Mathematical Literacy Hands-On Support Slide Show - Module 3 Part 1
NCV 4 Mathematical Literacy Hands-On Support Slide Show - Module 3 Part 1Future Managers
 
6 Function
6 Function6 Function
6 FunctionKwan Lee
 
cost_and_management_acc_accounting-manual
cost_and_management_acc_accounting-manualcost_and_management_acc_accounting-manual
cost_and_management_acc_accounting-manualmuumaimar
 
How to Find EAR and APR in MS Excel?
How to Find EAR and APR in MS Excel?How to Find EAR and APR in MS Excel?
How to Find EAR and APR in MS Excel?sadraus
 
Management consultancy-chapter-26-and-35
Management consultancy-chapter-26-and-35Management consultancy-chapter-26-and-35
Management consultancy-chapter-26-and-35Holy Cross College
 
Managerial Finance cw2 Management ReportWord Count2,500.docx
Managerial Finance cw2 Management ReportWord Count2,500.docxManagerial Finance cw2 Management ReportWord Count2,500.docx
Managerial Finance cw2 Management ReportWord Count2,500.docxcroysierkathey
 

Similar to List of programs to practice for ICSE (15)

Comp 122 lab 2 lab report and source code
Comp 122 lab 2 lab report and source codeComp 122 lab 2 lab report and source code
Comp 122 lab 2 lab report and source code
 
1 University of Leeds School of Computing Proced.docx
1 University of Leeds       School of Computing Proced.docx1 University of Leeds       School of Computing Proced.docx
1 University of Leeds School of Computing Proced.docx
 
Part I (Short Answer)1. In Java, what are the three different w.docx
Part I (Short Answer)1. In Java, what are the three different w.docxPart I (Short Answer)1. In Java, what are the three different w.docx
Part I (Short Answer)1. In Java, what are the three different w.docx
 
Comp 122 lab 3 lab report and source code
Comp 122 lab 3 lab report and source codeComp 122 lab 3 lab report and source code
Comp 122 lab 3 lab report and source code
 
Lecture#2
Lecture#2 Lecture#2
Lecture#2
 
COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEW
 
Topic 2 Cf And Making Investment Decisions
Topic 2 Cf And Making Investment DecisionsTopic 2 Cf And Making Investment Decisions
Topic 2 Cf And Making Investment Decisions
 
Chap. 7.pptx
Chap. 7.pptxChap. 7.pptx
Chap. 7.pptx
 
NCV 4 Mathematical Literacy Hands-On Support Slide Show - Module 3 Part 1
NCV 4 Mathematical Literacy Hands-On Support Slide Show - Module 3 Part 1NCV 4 Mathematical Literacy Hands-On Support Slide Show - Module 3 Part 1
NCV 4 Mathematical Literacy Hands-On Support Slide Show - Module 3 Part 1
 
6 Function
6 Function6 Function
6 Function
 
Cpph exam a_2019_s1
Cpph exam a_2019_s1Cpph exam a_2019_s1
Cpph exam a_2019_s1
 
cost_and_management_acc_accounting-manual
cost_and_management_acc_accounting-manualcost_and_management_acc_accounting-manual
cost_and_management_acc_accounting-manual
 
How to Find EAR and APR in MS Excel?
How to Find EAR and APR in MS Excel?How to Find EAR and APR in MS Excel?
How to Find EAR and APR in MS Excel?
 
Management consultancy-chapter-26-and-35
Management consultancy-chapter-26-and-35Management consultancy-chapter-26-and-35
Management consultancy-chapter-26-and-35
 
Managerial Finance cw2 Management ReportWord Count2,500.docx
Managerial Finance cw2 Management ReportWord Count2,500.docxManagerial Finance cw2 Management ReportWord Count2,500.docx
Managerial Finance cw2 Management ReportWord Count2,500.docx
 

More from Mokshya Priyadarshee

More from Mokshya Priyadarshee (6)

Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)
 
Mysteries Of The World
Mysteries Of The WorldMysteries Of The World
Mysteries Of The World
 
Layers of the atmosphere
Layers of the atmosphereLayers of the atmosphere
Layers of the atmosphere
 
Enviroment Impact Assesment
Enviroment Impact AssesmentEnviroment Impact Assesment
Enviroment Impact Assesment
 
Albedo and Radiation
Albedo and RadiationAlbedo and Radiation
Albedo and Radiation
 
Air purification And Modern Technologies To Purify Air
Air purification And Modern Technologies To Purify AirAir purification And Modern Technologies To Purify Air
Air purification And Modern Technologies To Purify Air
 

Recently uploaded

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 

Recently uploaded (20)

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 

List of programs to practice for ICSE

  • 2. 2 Simple programs using mathematical operators 1. Write a program to accept two numbers find and display the sum of two numbers. 2. Write a program to accept two sides of a rectangle. Compute and display the area and the perimeter of the rectangle. 3. Write a program to accept the radius of a circle. Compute and display the area and the circumference of the circle. 4. Write a program to accept the temperature in Celsius. Compute and display the equivalent temperature in Fahrenheit. [ f=9*c/5+32 ] 5. Write a program to accept two sides of a rectangle. Compute and display the length of the diagonal of the rectangle. 6. Write a program to accept the Principal, rate of interest and time. Compute and display the Amount, the Compound Interest and Simple Interest. 7. Write a program to accept three numbers. Compute and display the sum and the average of the three numbers. 8. A Computer manufacturing Company announces a special offer to their customer on purchasing Laptops and the Printers accordingly: On Laptop: Discount - 15% On Printers: Discount - 10% Write a program to accept the purchase price of Laptop and Printer, calculate the discount and display the net amount the customer will pay on his purchase. 9. In an election, two candidates A and B contested. A got 60% of the votes. Write a program to accept the total number of votes and calculate the number of votes each candidate got and display the result. 10. Write a program to accept the length of the perpendicular and base of a right angled triangle. Calculate and display the hypotenuse and area of the triangle. 11. Write a program to accept the basic pay of an employee, Compute and display the net pay of the employee based on following allowances and deductions: Dearness Allowance 25% of Basic Pay House Rent Allowance 15% of Basic Pay Provident Fund 10% of Basic Pay Gross Pay = Basic Pay + Dearness Allowance + House Rent Allowance Net Pay = Gross Pay – Provident Fund 12. Write a program to accept three sides of a triangle. Compute the area of the triangle using Hero’s formula i.e. area of a triangle = √s(s-a)(s-b)s-c) where s=( a + b + c)/2. Display the result. 13. Write a program to calculate the value of x and y if x= a2 + b3 and y = b3 – a2 where value of ‘a’ and ‘b’ is to be given as input. 14. Write a program to accept the purchase price of a TV and calculate the selling prices of TV which will give the shop keeper 15% profit and a loss of 5%. Display the selling prices in both the cases. 15. Write a program to accept the present population of a country and calculate the population after 7 years if the growth rate is 7% per year. Display the population at the end of 7th year. 16. Write a program to accept a number of seconds as input and convert the number to the corresponding number of hours, minutes and seconds and display it. 17. WAP to calculate the distance travelled by a person in the hours given as input, taking average speed of travelling as 40Km per hour. 18. Write a program to input the purchase price of a TV and display the price customer will pay. The shopkeeper allows 10% discount on purchase price and charges tax 12.5% on the net amount. 19. Write a program to input the input product code, price of product, quantity of product. Calculate the total cost and discount 12% on total cost. Find the net price to be paid for the product. Print all the data as output. 20. Write a program to swap the value stored in n1 and n2. Print the value before and after they are interchanged. 21. Write a program to input the total monthly income. Find the total income, tax discount 20% of the total income. Find total taxable income and sales tax at 15% of the taxable income. Display the net income. Programs using conditional statement – if ….. else statements 1. Write a program to accept any three numbers. Display the greatest among them. 2. Write a program to accept any three numbers and display the smallest number among them using nested if statement. 3. Write a program to accept any number and check if the number is odd or even. 4. Write a program to accept three numbers and check whether they are Pythagorean Triplet or not. The program must display message accordingly.
  • 3. 3 5. Write a program to accept any year and check if it is a leap year number or not. 6. WAP to input any year from 1000 to 2005 and print the number of days in that year. 7. WAP to accept three sides of a triangle and check whether the triangle is possible or not. 8. Write a program to accept the sides of a triangle and display whether it is an Equilateral or Isosceles or a scalene triangle. 9. Write a program to accept the cost price and the selling price of an article and calculate either profit percent or loss percent. 10. Write a program to accept any three digits number and count the numbers of odd digits present in it. If odd digits are not found display appropriate message. 11. Write a program to accept a three digit number and form the biggest number using the digits of the number and display the new number. 12. A bank offers the following denominations of notes: ` 500, ` 100, ` 50, ` 20, `10, `5, ` 2, ` 1 Write a program to accept the amount of money to be withdrawn and find out the number of notes of each denomination to be given by the bank. 13. Write a program to accept any number below 10000 and display the amount to be added to it to make the biggest number having same number of digits as of the number given as input. Use if else ladder to solve the problem. 14. Write a program to accept the class in which a student is taking admission and display the tuition fees he would have to pay per month using the table below: CLASS Tuition Fee per month 1 to 3 Rs. 500/- 4 to 7 Rs. 600/- 8 to 10 Rs. 950-/. 15. Write a program to calculate the library fine for the books returned late as per the following rules of the library: up to 5 day Rs. 0.40 per day Next 5 days Rs. 0.65 per day Above 10 days Rs. 0.80 per day 16. Write a program to check if a three digit number is a Armstrong number or not 17. In a firm employee is paid as follows: S.No. Basic Salary DA HRA ------------------------------------------------------------------------------------- 1. Less than 2000 10% 5% 2. Greater than equal to 2000 but less than 4000 25% 15% 3. Greater than equal to 4000 but less than 8000 30% 25% 4. greater than 8000 40% 30% -------------------------------------------------------------------------------------- Write a program to accept the Basic salary and calculate the gross salary and net salary aft er making following deductions: 1. P.F. at 10% of Basic Salary 2. I.T. at 2% of Basic Salary Display Gross Salary and Net Salary. 18. WAP to accept value of a, b, c and compute the roots and display following results. If b2 - 4ac results a positive answer display “REAL AND DISTINCT ROOTS” If b2 - 4ac results a negative answer display “IMAGINARY ROOTS” If b2 - 4ac results 0 display “REAL AND EQUAL ROOTS” 19. Write a java program to find the solution of any pair of linear simult aneous equation as follows: ax + by = c px + qy = r The program should: (i) accept values of a, b, p, q and r. (ii) Use x = (cq – br)/ aq – bp) and y = (ar – cp)/aq – bp) (iii) print “No finite solution” if aq – bp = 0. 20. During sale a shop offers discount on the total purchases made by any customer. If the purchase is less than Rs. 1000.00 the rate of discount is only 5%, for purchase from Rs. 1000.00 to 4999.00 rate of discount is 10% and purchase of Rs.5000.00 and above the rate of discount is
  • 4. 4 15%. Write a program to input the purchase amount and find the discount and amount to paid by the customer. 21. Write a program to calculate the Telephone bill according to the following rules: i. Minimum of Rs.250.00 is charged as rent. ii. First 80 calls FREE iii. Next 60 call @ Rs.0.60 iv. Next 60 call @ Rs.0.50 v. Above 200 call @ Rs.0.40 22. Write a program to calculate electricity bill for the number of units consumed given as input, following the rules given below Minimum Meter rent charges Rs.100.00 Up to 250 units Rs.0.80 per unit Above 250 units Rs.1.50 per unit 23. Given three numbers A, B and C, Write a program to write their value in an ascending order. For Example, if A=12, B=10 and C=15, your program should print out as under Smallest Number = 10 Next higher number = 12 Highest Number = 15 24. In an office there are three grades of employees, namely, A, B and C. Write a program to accept the Pay and the Grade and calculate bonus obtained by them as per following rules: For grade A Bonus = 10% of Pay For grade B Bonus = 12% of Pay, subject to maximum of Rs.2000.00 For grade C Pay up to Rs.5000.00 5% of Pay Pay above Rs.5000 to Rs.8000 7% of Pay Pay above Rs. 8000.00 10% of Pay 25. Write a program in Java to calculate the income tax paid by Mr. Kartar Singh to the Govt. of India on his annual income as per the slab given below: Slab Income Tax Up to Rs. 50,000 No Tax Rs.50,001 to Rs.60,000 10% of the amount exceeding Rs.50,000/- Rs.60,001 to Rs.1,50,000 Rs.1000 + 20% of the amount exceeding Rs.60,000/- Rs.1,50,000 and above Rs.19,000 + 30% of the amount exceeding Rs.1,50,000/- Take annual salary as input and display the income tax to be paid by him. 26. Write a program to compute charges for sending parcels when the charges are as follows: For the first 1000gms Rs.15.00 and for additional weight of every 500gms or fraction thereof Rs.8.00. Accept the total weight of the parcel and display the charges 27. A security agency pays to their staff as per the tariff given below: Hours Rate For first 48 hours in a week Rs. K per hour For next 8 hours in a week Rs.1.25K per hour For further hours in a week Rs.1.50K per hour Write a program in Java to calculate the weekly wages of the staff taking number of hours and rate per hour as inputs. 28. Write a program that displays the number of notes in each of the denominations i.e. number of 1000 rupees not, number of 500 rupees notes, number of 100 rupees notes Till number of 5 rupees note, for a given amount. 29. DTDC courier service charges for the transportation of any parcel within eastern zone as follows: Up to 100gms. : Rs.30.00 For each additional 50gms.or part thereof : Rs.10.00 Write a program to calculate the charges of a parcel taking the weight of the parcel as an input. 30. ABC Limited revised its rate of interest for public deposits as follows: YEARS CUMULATIVE INTEREST ANNUAL INCOME SCHEME Scheme (p.a.) (Compounded Annually) 1 --- 11% 2 --- 11.5% 3 12.5% 12% 4 12.5% 12% 5 12.5% 12% Deposit under the cumulative scheme is accepted for a period of 3 to 5 years only. Write a program in Java ti find the: (i) amount (A) due for sum (P) invested under the cumulative option scheme, by using the formula A = P * [1 + (0.01 * r)]t
  • 5. 5 (ii) interest (I) for each year under the annual interest scheme, using the formula I = 0.01 * P * r * t. 31. Write a program to accept length and breadth of a rectangle. Calculate and display the area, perimeter or diagonal of the rectangle as per user’s choice. 32. Write an menu driven program to find the area of an Equilateral triangle, an isosceles triangle and a scalene triangle as per User’s choice. 1. Equilateral Triangle =√3/4 8 s2, s = side of an equilateral triangle 2. Isosceles Triangle = ¼ * b * √4a2 – b2, a = equal sides of a triangle, b = base 3. Scalene triangle = √s * √s(s-a)(s-b)s-c) where s=( a + b + c)/2, a, b, c are three sides of a triangle. 33. Write a menu driven program to find the sum, difference and product of two numbers. Perform the tasks accordingly. Enter ‘+’ to find sum, ‘-’ to find the difference and ‘*’ to find the product of two numbers. 34. Using switch case statement, write a menu driven program to convert a given temperat ure from Fahrenheit to Celsius and vice versa. For an incorrect choice an appropriate error message should be displayed. [C = 5.0/9.0 (F – 32) and F = 1.8 * c + 32] 35. Write a menu driven program to calculate the following: 1. Area of a circle = PI * r2 (PI=22.0/7.0) 2. Area of a square = side * side 3. Area of a rectangle = length * breadth. 36. Write a menu driven program to calculate the following: 1. Volume of a cube = side * side * side 2. Volume of a sphere = 4.0/3.0 * PI * radius * radius * radius (PI=22.0/7.0) 3. Volume of a Cuboid = length * breadth * height. 37. Write a menu driven program to perform either of the following conversions depending on the user’s choice: (i) KM to CM (ii) Hours to Minutes (iii)Centigrade to Fahrenheit Programs using for Loop Statements 1. Write a program to find the sum of the even & odd numbers from 1 to 100. 2. Write a program to accept 10 different numbers and display the greatest and the smallest of the numbers. 3. Write a program to print first 50 numbers of Fibonacci series. 4. Write a program to print the mathematical table of any given number. 5. The production (P) of crude oil of a country in millions of barrels may be estimated by the following set of equations, where t represents the time in years. P = 5 + 3t. 0 ≤ t ≤ 3, P = 14 + (t – 5 /2)2, for t > 3. Write a program in java to find the production for every year from t = 1 to 10 and print it. 6. Write a program to print the number of leap year till the current year. Leap year condition is [if(y%400==0 || y%100!=0 && y%4==0)]. 7. Write a program to display the value of ‘x’ and ‘fx’ if fx = (x2+1)/(x2 – 1) and x ranges from 0 to 2.5 in step of 0.5. Take the value of fx = 0 when x = 1.0. 8. The population of a country at the end of the year can be found out by multiplying the population (P) at the beginning of the year by (1 + X/100) where X is the growth rate of the population. Taking as input the population (P) at the beginning of the year 1999 and the growth rate (X), write a program to find the population at the beginning of each year from 2000 to 2014. 9. Write a program to calculate and print the value of Y where Y equals to: Y = (n6 + n4 + n2 + 10)/(n5 + n3 +n) for n ranging from 10 to 100 in step 5. 10. Write a program to calculate and print the factorial value of any single digit number. 11. Write a program to print all the Pythagorean triplets between 1 and 50. 12. Write a program to accept a number and find the minimum prime digit of the number. 13. Write a program to compute and print all the prime numbers between 100 and 500. 14. Write a program to display all the set of 5 consecutive composite numbers between 1 and 100. 15. Write a program to calculate the sum of all 3 digit prime number. 16. Write a program to accept a number and check if it is Armstrong prime or not. 17. Write a program to display all the Armstrong number between 100 and 999 in ascending as well as in descending order. 18. Write a program to calculate and print the HCF and LCM of any two numbers using for loop. 19. Write a program to accept two numbers and find their LCM without finding the HCF.
  • 6. 6 20. Write a program to compute the following of any given number: 1. All the factors of the number 2. All the even factors of the number 3. All the odd factors of the number 4. All the prime factors of the number 21. Write a program to find out the integer between 1 and 10000 that has the largest number of divisors. Print out the maximum number of divisors and an integer that has that many divisors. 22. Write a program to check if the number is perfect or not. 23. Write a program to find and print all the perfect number between 1 and 100. [Perfect number is the number, which equal to the sum of its factor other than the number itself. For example 6=1+2+3] 24. Write a program to check and list all the special number between 1 and 1000. 25. Write a program to display all the prime Fibonacci series between 1 an 1000. 26. Write a program to display following output: 1 2 3 4 5 1 1 1 1 1 1 2 3 4 5 1 2 3 4 5 5 5 5 5 9 9 9 9 9 1 2 3 4 5 2 2 2 2 2 2 3 4 5 6 5 6 7 8 5 4 4 4 4 9 7 7 7 7 1 2 3 4 5 3 3 3 3 3 3 4 5 6 7 9 10 11 12 5 4 3 3 3 9 7 5 5 5 1 2 3 4 5 4 4 4 4 4 4 5 6 7 8 13 14 15 16 5 4 3 2 2 9 7 5 3 3 1 2 3 4 5 5 5 5 5 5 5 6 7 8 9 17 18 19 20 5 4 3 2 1 9 7 5 3 1 27. Write a program to display following output: 1 1 1 2 3 4 5 11 1 2 3 4 5 6 7 5 5 5 5 5 1 2 2 2 1 2 3 4 12 22 1 2 3 4 5 4 4 4 4 1 2 3 3 3 3 1 2 3 13 23 33 1 2 3 3 3 3 1 2 3 4 4 4 4 4 1 2 14 24 34 44 1 2 2 1 2 3 4 5 55 5 5 5 1 15 25 35 45 55 1 1 1 2 3 4 5 15 14 13 12 11 1 3 5 7 9 3 1 6 7 8 9 10 9 8 7 3 5 7 9 1 5 3 1 10 11 12 6 5 4 5 7 9 1 3 7 5 3 1 13 14 3 2 7 9 1 3 5 9 7 5 3 1 15 1 9 7 5 3 1 28. Write a program to display following output: 1 1 1 5 4 3 2 1 1 2 1 12 2 4 5 4 3 2 1 2 6 1 12 123 3 6 9 5 4 3 1 2 6 24 1 12 123 1234 4 8 12 16 5 4 1 2 6 24 120 1 12 123 1234 12345 5 10 15 20 25 5 29. Write a program to display following output: 1 5 1 1 2 3 4 5 6 1 1 2 1 4 5 2 2 1 1 1 1 1 2 3 1 2 1 3 2 1 3 4 5 3 3 3 1 1 1 2 3 4 5 1 2 3 2 1 4 3 2 1 2 3 4 5 4 4 4 4 1 2 3 4 5 6 7 1 2 1 5 4 3 2 1 1 2 3 4 5 5 5 5 5 5 1 30. Write a program to display following output: 0 0 0 0 1 1 0 1 0 1 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 0 0 0 1 0 0 1 0 1 0 2 2 2 1 3 1 2 2 2 1 1 2 2 2 1 0 1 0 1 0 0 0 1 0 0 1 0 1 0 1 2 2 1 3 3 1 2 2 2 1 1 2 3 2 1 0 0 1 0 0 0 1 0 0 0 0 1 0 1 0 2 1 3 3 3 1 2 2 2 1 1 2 2 2 1 0 1 0 1 0 1 0 0 0 0 1 0 1 0 1 1 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 0 1 0 1 1 0 0 0 0 * * * * $ 1 0 1 0 1 0 0 1 0 0 0 * * * $ * 1 0 1 1 0 1 0 0 1 0 0 * * $ * * 1 0 1 0 1 0 0 0 0 1 0 * $ * * * 1 0 1 0 1 1 0 0 0 0 1 $ * * * * 31. Write a program to display following output: 1 1 `567898765 97531 25 1 1 1234554321 232 121 4567654 7531 16 13 4 1234 4321 34543 12321 34543 531 09 135 9 123 321 4567654 1234321 232 31 04 1357 16 12 21 567898765 123454321 1 1 01 13579 25 1 1 32. 1 22 333 4444 55555 33. 2 5 10 17 26 ….. 10th 34. 1 12 123 1234 12345
  • 7. 7 35. 1 11 111 1111 11111 36. 0 3 8 15 24 35 48 63 80 99 [2011] 37. 1 3 7 15 31 63 127 255 511 1023 38. Write a program to calculate the sum of following series: 1. S = 1*2 + 2*3 + 3*4 + 4*5 ………….+(19*20). 2. S = 1 + (1+2) + (1+2+3) + (1+2+3+4) + ……….. +(1+2+ ….. +n) 3. P = 1 * (1+2) * (1+2+3) * (1+2+3+4) * ……….. *(1+2+ ….. +n) 4. S = 1 + 1/3 +1/5 + 1/7 + …… + 1/n 5. S = 1 + 3 + 5 + 7 + ……. + n 6. S = +1-2+3-4+5-6+ ………. + n 7. S = 2 + 4 + 6 + 8 + ……. + n 8. S = 2 + 5 + 10 + 17 + 26 + ………10th term 9. S = 1*2*3*4 + 2*3*4*5 + 3*4*5*6 + ……. + 7*8*9*10 10. S = 12 + 22 + 32 + 42 + …… +252 11. S = 1 + 4 + 9 + 16 + 25 + ……… + nth terms 12. S = 1/1! + (1+2)/2! + (1+2+3)/3! + (1+2+3+4)/4! + ------+(1+2+3+----+N)/N! 13. S= 1 + 3 + 7 + 15 + 31 +- - - - - -+ nth terms 14. S = 0.5 +0.05 +0.005 + 0.0005 + - - - - - -+8th term. 15. S = x1/1! + x2/2! + x3/3! + x4/4! + .- -- --- + xn/n!. 16. S = 1 + 1/(1+2) + 1/(1+2+3) + 1/(1+2+3+4) + -- - - - +1/(1+2+3+ - - - - +n) 17. S = 1+a/2+a2/3+a3/4+---------------+an-1/n Where a and n is given as input. 18. S = 1+a/2!+a2/3!+a3/4!+---------------+a10/11! Where a is given as input. 19. S = 1- a/2! + a 2/3! – a3/4!+---------------+a19/20! Where a is given as input. 20. S = ¼+1/8+1/12+ ..... up to n terms. 21. S = 1/1! – 2/2! + 3/3! – 4/4! ........up to n terms. 22. S = x2/2! + x5/4! + x8/8! .... up to n terms. 23. S = 1! + 2! + 3! + 4! + . . . . . . . . +n! 24. S = (24 * 1) + (21 * 2) + (18 * 3) + (15 * 4) + . . . . . . . . up to n terms. 25. S = 1! +2! +3! + 4! + . . . . . . . . . . . to n terms 26. S = ½ + 2/3 + ¾ + 4/5 + . . . . . . . . to n terms 27. S = 9 + 99 + 8 + 89 + 7 + 79 + . . . . . . . to n terms Programs using while and do while Loop Statements 1. Write a program to print the 52nd term of the Fibonacci series. 2. Write a program to print the Fibonacci series below 750. 3. Write a program to accept a number and check whether the number is present in the Fibonacci series or not. 4. Write a program to input any number and out following results: i. Print the digits in reverse order. iii. Product of the individual digits ii. Sum of the individual digits iv. Arrange the digits in descending and ascending order v. Find the Smallest Digit vi. Find the biggest digit 5. Write a program to accept a number and display the frequency of each digit present in the number. 6. Write a program to input any five digit number and form the biggest number using the digits of the number given as input. [Example: Input number – 67539 program output should be 97653] 7. Write a program to input any five digit number and form the biggest number using the digits of the number given as input. [Example: Input number – 67539 program output should be 35679 OR Input Number 50143 Output should be 10345] 8. Write a program to check if the given number is a palindrome number or not. 9. Write a program to input any number and generate a palindrome number using the number given as input. 10. Write a program to accept a number and find out the sum of the squares of the digits of the number. 11. Write a program in java to calculate the fare for passengers travelling on a computerized bus. As a passenger enters the bus, the computer displays “What distance will you travel?” On entering the distance, the fare is displayed on the screen according to the following table: Distance Fare Up to 15 KM Rs. 5.00 Up to 25 KM Rs. 10.00 Above 25 KM Rs. 15.00 The computer keeps on adding and displaying the total fare after each passenger has entered the distance and the program ends when the distance entered as “0”. It then displays the total number of passengers who entered the bus and the total fare collected.
  • 8. 8 12. Write a program to display first 50 prime numbers from a given number. 13. A prime number is said to be “Twisted Prime”, if the new number obtained after reversing the digits is also a prime number. Write a program to accept a number and check whether the number is “Twisted Prime” or not. 14. Write a program to accept any number and find the sum of its prime digits. 15. Write a program to accept a number and check if it is prime number or not. 16. Write a program to accept a number and check if it is automorphic number or not. 17. Write a program to display all the automorphic numbers between 1 and 10000. 18. Write a program to calculate and print the HCF and LCM of any two numbers using division method. 19. Write a program to check if the number is special or not. [A number is equal to the sum of the factorial of each digit] [2011] 20. Write a program to input a number and check if the number is magic number or not. 21. Write a program to calculate and print the Binary equivalent of any number. 22. Write a program to calculate and print the Decimal equivalent of any binary number. 23. Write a program to convert a given decimal number to octal number. 24. Write a program to calculate and print the Decimal equivalent of any octal number. 25. Write a program to enter a number and check whether the number is neon number or not. A number is said to be “Neon”, if the sum of the digits of the square of a number is equal to number itself. 26. Write a program to accept a number and check whether the number is Unique or not. A number is said to be unique if digits of a number are not repeated. 27. Write a program to accept a number and check whether the number is a Duck number or not. A number is said to be Duck if the digit zero is present in it. 28. Write a program to accept a number and display the new number after removing all zeros. 29. Write a program to accept two numbers M and N consisting of two digits each and use Russian Peasants method to find the product of M and N. The logic of the method is explained below with a example. M N P 17 20 20 8 40 20 4 80 20 2 160 20 1 320 340 0 program stops and displays value of P Program using Constructors and Constructor overloading: 1. Write class Students definition with the following members: Data Members: Roll No., Height, Weight. Member Functions/Methods: get( ) to accept data as parameters and initialize data members set ( ) to increase the height in field height based on the parameter. print ( ) to display the data. 2. Write class definition with the following members: Data Members: Roll No., Height, Weight. Member Methods: constructor function to initialize data members by default value of height as 5.5 feet and weight as 50 Kg display ( ) to display the data. 3. Write a java class Time with the following specifications: Data Members Member functions Hour default constructor to initialize time Minutes parameterized constructor: initialize time Seconds show( ) : display time reset ( ) : reset time 4. Write a java class Date and define a constructor for the class for the following specification. Data Members Member functions Day (dd) default constructor to initialize date Month (mm) parameterized constructor to initialize date of birth Year (yy) yearPlus( ) : to increase the year of date by 1 display( ) : display date. 5. Define a class student having the following description: Data members/Instance variable: String name : to store the name of the student.
  • 9. 9 int roll : to store the roll number of the student. int p,c,b : to store his physics, chemistry and biology marks double S : to store his science marks (average of physics, chemistry and biology) Member function: input () : to input the details. calculate () : to calculate the science marks. display () : to display the details in following format: Name Roll No. Science Marks Also write the main method to create an object and call the above methods. 6. Design a class using proper constructors to represent a bank account. Including the following members. Data Members Member functions Name of the depositor Parameterized constructor to assign initial value Account Number To deposit an amount Type of Account To withdraw an amount after checking the balance Balance amount in the account To display the name and balance 7. Define a class Pay in java with following specification: Data Members Member functions String name, address *Pay(String n, String add, String cy, Float s)- & city *Parameterized constructor to initialize the data members. double salary, da, hra, *void outputData( )-to display initial values pf, gs, ns *void calculate( ) – to calculate following details: da = 15% of salary hra = 10% of salary pf = 12% of salary gs = salary + da + hra ns = gs – pf *void display( ) – to display the complete information Program using Function, Function overloading 1. Define a class with following functions: 1. circle(pie * r2 ) where pie = 3.14 to find the area of circle 2. Square (side * side) to find the area of square 3. Rectangle (length * breath) to find the area of a rectangle 2. Define a class to overload a function area( ) as follows: 1. void area (double r) to compute the area of a circle where pie = 3.14 2. void area (int s) to compute the area of a square 3. void area (int l, int b) to compute area of a rectangle. 3. Define a class to overload a function number ( ) as follow: 1. void greatest (int a, int b, int c) to display the greatest. 2. void greatest (double a, double b, double c) to display the greatest 3. void greatest ( int a, double b, double c) to display the greatest String handling programs to practice 1. Write a program to display the number of vowels found in any given string. 2. Write a program to accept a sentence and find out the percentage of vowels in that sentence. 3. Write a program to accept a sentence and find out the number of vowels and the number of consonants in the sentence. 4. Write a program to accept a word and display the new sword after removing the vowels present in the word. Example: COMPUTER APPLICATION --> CMPTR PPLCTNS 5. Write a program to accept a string in uppercase and find the frequency of each vowel present in the string. 6. Write a program to print the given word in reverse. 7. Write a program to display the number of words and blank space in any given sentence. 8. Write a program in Java to accept a sentence and find the average number of alphabets present in each word of the sentence. 9. Write a program to accept a sentence and reverse it word by word. For example, if the input is THIS DOON SCHOOL the output should be SCHOOL DOON IS THIS. 10. Write a program to display each word in reverse of any given string. 11. Write a program to print the frequency of all the characters within a string. 12. Write a program to print the alphabets of any given word in alphabetic order. 13. Write a program to find and print the longest and the shortest word in any given string.
  • 10. 10 14. Write a program to count the number of upper case and lower case alphabets in a string. 15. Write a program to count the number of alphabets, special characters and digits in any given sentence. 16. Write a program to convert first letter of each word to upper case. 17. Write a program to check if the given word is palindrome or not. 18. Write a program to compute the sum of ASCII codes of the vowel present in any string. 19. Write a program to accept a sentence and display all the words in separate lines along with their length. 20. Write a program to accept a sentence having letters in upper case and lower case. Display the sentence after change the upper case letters to lower case and vice versa. For example:- Input – He is a Bad Boy. Output – hE IS A bAD bOY. 21. Write a program having replaceWord ( ) function, which take three parameters, one, the sentence, two, the word to be replaced, third, the new word. Print the sentence with new word in it. For example: “Today is my practical class” output – “Today is my theory class” 22. Write a program having deleteWord ( ) function, which take two parameters, one, the sentence, two, the word to be deleted. Prints the modified sentence. For example: “I will never come to your house” output – “I will come to your house”. 23. Write a program to accept a sentence and print only the first letter of each word of the sentence in capital letters separated by a full stop. Example: INPUT Sentence: “Come let us bat” OUTPUT: C.L.U.B. 24. Write a program to print your name in abbreviated form. For example: Subhash Chandra Bose Output – S. C. Bose. 25. Write a program to print your name in abbreviated form. For example: Subhash Chandra Bose Output –Bose, S. C. 26. Write a program to print your name and print the surname first and then the name, separated by comma. For example: Subhash Chandra Bose Output –Bose, Subhash Chandra. 27. Write a program to count number of digits present in a sentence, if no digits are found display appropriate message. 28. Write a program to display following string formats: c computer c ABCDEFGHHGFEDCBA R co compute c o ABCDEFGHHGFEDCBA ER com comput c o m ABCDEFGHHGFEDCBA TER comp compu c o m p ABCDEFGHHGFEDCBA UTER compu comp c o m p u ABCDEFGHHGFEDCBA PUTER comput com c o m p u t ABCDEFGHHGFEDCBA MOUTER compute co c o m p u t e ABCDEFGHHGFEDCBA OMPUTER computer c c o m p u t e r ABCDEFGHHGFEDC A COMPUTER 29. Write a program to display following string formats: a A a u t s r q p * U BLUEJ b c b C b c o n m l k P * U P U T LUEJB d e f d E f d e f j i h g M P * U T M P U T E UEJBL g h i j G h I j g h i j f e d O M P * U T E O M P U T E R EJBLU k l m n o K l M n O k l m n o b c C O M P * U T E R C O M P U T E R S JBLUE p q r s t u p Q r S t U p q r s t u a 30. Write a program to store “DONBOSCO” in an appropriate variable and generate the following output D D O D O N D O N B D O N B O D O N B O S D O N B O S C D O N B O S C O 31. Program which replaces each character in s by the character which is at a distance of move ahead, if move is positive. If move is 0 the original string is returned unchanged. If move is negative, then each character is replaced by a character at a distance move behind it. For example: When s=”ABCXYZ”, encodeDecode (2) returns “CDEZAB” and When s=”ABCDE”, encodeDecode (-3) returns “XYZAB” 32. Program to input a sentence and display words that are starting with vowel.
  • 11. 11 33. Write a program to accept a word and generate a PIG LATIN word. [Example – Word – KING output – INGKAY or TROUBLE output OUBLETRAY] 34. Write a program to accept a String and display only those characters which are consecutive: Sample Input: UNDERSTANDING COMPUTER APPLICATIONS Sample output: D, E R, S S, T are consecutive characters. 35. Write a program to accept a String and count how many times a Alphabet is used repeatedly: Sample Input: Application of scanner class in java programme Sample output: 4 36. Write a program to input your mane and display your name with all the vowels in uppercase and others in lowercase. 37. Write a program to input two strings and check if they are anagram or not. Two strings are said to be anagram if the same alphabets of one string is used in the second string. For example SCHOOL MASTER AND THE CLASS ROOM. 38. Write a program to accept a word and display ASCII value of each character. 39. Write a program to accept a word and display the new word after removing all the repeated alphabets. 40. Write a program to accept a string and check whether the string is Unique or not. A string is said to be Unique if none of the alphabets in the string are repeated. Array handling programs 1. Write a program to input 10 values into an array and display the square of each element of the array. 2. Write a program to store 15 values in Array A and add 5 to each element and store it in Array B. 3. Write a program to store 20 values in an array and display the array in reverse order. 4. Write a program to store 10 values in two arrays X and Y and check if they are identical or not. 5. Write a program to find the largest and the smallest number in an array. 6. Suppose A, B, and C is arrays of integers of sizes m, n, and m + n respectively. Write a program to produce a third array C, containing all the data of array A and B. 7. Write a program to check whether or not two arrays (of characters) are identical, that is, whether they have same characters and all characters in corresponding positions are equal. 8. Write a program using array to find the ASCII code of the following characters: A, B, 8, <, AND !. 9. Write a program to print the given number in words. For example if the given number is 124356 then in should output “one lakh twenty four thousand three hundred fifty six”. 10. Write a program using arrays that stores the name, English Marks, Math Marks and Science Marks for 40 students. The program should calculate the total marks and percentage of each students and the average marks obtained by the class in each subject. 11. Write a program to store 15 19 25 36 48 59 67 72 83 99 in an array and perform Binary Search in an array for a number given as input. 12. Write a program to store 15 12 62 54 32 86 72 55 43 91 in an array and perform Linear Search in a given array for a number given as input. 13. Write a program to store 15 19 25 36 48 59 67 72 83 99 in an array and Sort the array using Bubble Sort Method. 14. Write a program to store 15 19 25 36 48 59 67 72 83 99 in an array and Sort the array using Selection Sort Method. 15. The names and Computer Application marks of 80 students are to be stored in arrays N[x] and M[x]. Write a program to store the data and also arrange the data in alphabetical order of names using Bubble sort method. 16. Write a program to store 15 numbers in an array and delete the element from a position chosen by the user. Display both original and the modified array. 17. Write a program to store 15 numbers in an array and insert one element at the position chosen by the user. Display both original and the modified array. 18. Write a program to store the names of the ten cricket players, number of innings played, and runs scored. Input any one players name and search the array and display the number of innings played and runs scored by him. 19. Write a program to take a sentence having repeated words in it. Display each word and the frequency of that word in the sentence. 20. Write a program to store Roll numbers, names and marks of 10 students. Display the list in descending order of marks. 21. Write a program to lexicographically arrange the ten words stored in an array.
  • 12. 12 22. Write a program to store 20 different names in Single Dimensional array and display only those name which begin with a vowel. 23. Write a program to delete duplicate (repeated twice only) elements from a single dimensional array of characters. Display the array with unique elements. 24. Write a program to display Pascal’s triangle as shown below: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 25. Write a program to store 10 words in an array and display the words in descending order of their length. 26. Write a program where two single dimensional array each of size [10], one having names of the state and other having their state capitals. Input any state name and display its capital and if the state does not exists, give appropriate message. Program should continue to work till the user wants it to run. 27. Write a program to store data 5, -7, 3, -4, -6, 2, 9, -8, 1 in an array and arrange the array by keeping the positive number on left side and negative number on right side without changing the sequence in the original array (without another array)as show here 5, 3, 2, 9, 1, -7, -4, -6, -8 Programs using BufferedReader class (using keyboard to input values during execution) 1. Write a program to accept a five digit integer from keyboard and output the following: a. The message ‘Invalid Data’ has to be printed for the following cases: 1. If the number of digits is less than 5 or greater than 5. 2. If any of the digits is zero. b. If the number is found to be valid then find: 1. The absolute difference between first an last digit. 2. The absolute difference between the original number and the number obtained by reversing the digits 2. Write a program to input temperature of 12 months from the keyboard. Compute and display the average temperature and the maximum temperature. 3. Write a program to input a value from the keyboard and generate a palindrome number from it. Display the number and the palindrome number. 4. Write a program to print the sum of negative numbers, sum of positive even numbers and sum of positive odd numbers from a list of numbers entered by the user from the keyboard. The list terminates when the user enters a zero. ICSE questions [2005] 1. Write a class with employee name and basic pay as its data member. Compute and display the net pay of the employee based on following allowances and deductions: Use meaningful variables. Dearness Allowance (DA) 25% of Basic Pay House Rent Allowance (HRA) 15% of Basic Pay Provident Fund (PF) 10% of Basic Pay Gross Pay(GP) = Basic Pay + DA + HRA Net Pay = GP– PF 2. Write a program to input any given string to calculate the total number of characters and vowels present in the string and also reverse the string: Example: Input Enter String: SNOWY OUPUT: Total Number of Characters : 5 Number of vowels : 1 Reverse String : YWONS 3. Write a program using a function called area() to compute the area of a: i) circle ii) Square iii) rectangle Display the menu to output the area as per User’s choice. 4. Write a program to bubble sort the following set of values in ascending order. 5, 3, 8, 4, 2, 9, 1, 12, 98, 16 5. Write as program to print the sum of negative numbers, sum of positive even numbers, and sum of positive odd numbers from a list of number entered by the user. The list terminates when the user enters a zero. 6. Write a program to initialize an array of 5 names and initialize another array with their respective telephone numbers. Search for a name input by the user in the list. If found display
  • 13. 13 “Search Successful” and print the name along with the telephone number, otherwise “Search Unsuccessful, name not enlisted”. ICSE questions [2006] 1. A cloth showroom has announced the following festival discounts on the purchase of items, based on the total cost of the item purchased:- Total Cost Discount (in %) Less than Rs. 2000 5% Rs.2000 to Rs.5000 25% Rs.5001 to Rs.10000 35% Above Rs.10000 50% Write a program to input the total cost and to compute and display the amount to be paid by the customer after availing the discount. 2. Write a program to output the result of the following based on the number entered by the User. i. Natural logarithm of the number ii. Absolute value of the number iii. Square root of the number iv. Random number between 0 and 1 3. The Marks obtained by 50 students in a subject is tabulated as follows: Name Marks Write a program to input the names and marks of the students in the subjects and calculate and display: 1. The subject average marks 2. The highest marks in the subject and name of the student. (The maximum marks in the subject are 100) 4. Write a program to initialize a string with “January 26 is celebrated as the Republic Day of India” and change the sentence to “August 15 is celebrate as the Independence Day of India”. 5. Write a program to calculate and print the sum of odd numbers and the sum of even numbers for the n natural number. The integer n is to be entered by the User. 6. Write a program to accept 15 integers from the keyboard, assuming that no integer entered is zero. Perform selection sort on the integer and then print them in ascending order. ICSE questions [2007] 1. Define a class Salary as per the details given below: Data Members : Name, Address, Phone, Subject Specialisation, Monthly salary, Income Tax. Member Methods : 1. to accept the details of the teacher including monthly salary 2.To compute annual income tax at 5% of the annual salary above Rs.1,75,000/- 3.To display the details of the teacher 2. Write a program to compute and display the sum of the following series: 1 + 2 1+2+3 1+2+3+4 1+2+3+4+ -------+n ------ + -------- + ----------- + ----------------------- 1 * 2 1*2*3 1*2*3*4 1*2*3*4*--------*n 3. Write a program to initialize the given data in an array and find the minimum and maximum value along with the sum of the given elements Numbers : 2 5 4 1 3 Output : Minimum Value : 1 Maximum Value : 5 Sum of the elements : 15 4. Write a program to enter a sentence from the keyboard and count the number of times a particular word occurs in it. Display the frequency of the search word. 5. Using switch case 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.] 6. Write a program using a method Palin( ) to check whether a string is a Palindrome or not. A Palindrome is a string that reads the same from left to right and vice versa. ICSE questions [2008] 1. Define a class Employee having the following description: Data Member/Instance Variable: int panto store personal account number String name to store name double taxincome to store annual taxable income double tax to store that is calculated Member functions/Methods : input( )store the PAN number, name and taxable income +
  • 14. 14 calc( ) Calculate tax for an employee display( ) output details of an employee. Write a program to compute the tax according to the given conditions and display the output as per given format. Total Annual Taxable Income Tax Rate Up to Rs.1,00,000 No Tax From Rs.1,00,001 to 1,50,000 10% of the income exceeding Rs.1,00,000 From Rs.1,50,001 to 2,50,000 Rs.5,000 + 20% of the income exceeding 1,50,000 Above Rs.2,50,000 Rs.25,000 + 30% of the income exceeding 2,50,000 Output: PAN Number Name Tax-income Tax 2. Write a program to input a string and print out the text with the uppercase and lowercase letters reversed, but all other character should remain the same as below: Example : INPUT : WelComE to School OUTPUT : wELcOMe TO sCHOOL 3. Define a class and store the given city names in a single dimensional array. Sort these names in alphabetical order using Bubble Sort technique only. INPUT : Delhi, Bangalore, Agra, Mumbai, Calcutta OUTPUT : Agra, Bangalore, Calcutta, Delhi, Mumbai 4. Write a menu driven class to accept from the user and check whether it is a Palindrome or a Perfect number. 1.Palindrome Number: (a number is a Palindrome which when read in reverse order is same as read in the right order. Example: 11, 101, 151 etc) 2.Perfect number : (a number is called perfect if it is equal to the sum of its factors other than the number itself. Example : 6 = 1+2+3) 5. Write a class with the name Volume using function overloading that computes the volume of a cube, a Sphere and a cuboids. 1. Volume of cube : vc = s * s * s; 2. Volume of sphere: vs = 4.0/3.0 * π * r * r * r; (where π = 3.14 or Math.PI) 3. Volume of cuboids : vcd = l * b * h 6. Write a program to calculate and print the sum of each of the following series: 1. Sum (S) = 2 – 4 + 6 – 8 + ---------- -20 2. Sum (S) = x/2 + x/5 + x/8 + x/11 + ----------- + x/20 (value of x to be input by user) ICSE questions [2009] 1. An electronics shop has announced the following seasonal discounts on the purchase of certain items. Write a program based on above criteria, to input name, address, amount of purchase and the type of purchase (L for laptop and D for Desktop) by a customer. Compute and print the net amount to be paid by a customer along with his name and address. (HINT: discount = (discount rate/100)*amount of purchase. Net Amount = amount of purchase – discount) 2. Write a program to generate triangle or an inverted triangle till n terms based upon the user’s choice of the triangle to be displayed. Input user’s choice: 1. Triangle 2. Inverted triangle Input number of terms: If number of terms is 5 if choice is inverted triangle OUTPUT: if choice is Triangle 1 5 5 5 5 5 2 2 4 4 4 4 3 3 3 3 3 3 4 4 4 4 2 2 5 5 5 5 5 1 3. Write a program to input a sentence and print the number of characters in the longest word of the given sentence. For Example if S = “India is my country” then the output should be 7 4. Design a class to overload a function num calc( ) as follows: a. void num_calc(int num, char ch) with one integer argument and one character argument, computes the square of integer argument if choice ch is ‘s’ otherwise finds its cube. b. void num_calc(int a, int b, char ch) with one integer argument and one charact er Purchase Amount in Rs. Discount on Laptop Discount on Desktop PC 00000 – 25000 25001 – 57000 57001 – 100000 More than 100000 0.0% 5.0% 7.5% 10.0% 5.0% 7.5% 10.0% 15.0%
  • 15. 15 argument, computes the product of integer argument if choice ch is ‘p’ otherwise adds the integers. c. void num_calc(String s1, String s2) with two String arguments, which prints whether the strings are equal or not. 5. Write a menu driven program to accept a number from the user and check whether it is a “BUZZ” number OR to accept any two numbers and print the ‘GCD’ of them. 1. A BUZZ number is the number which either end with 7 or divisible by 7. 2. GCD (Greatest Common Divisor) of two integers is calculated by continued division method. Divide the larger number by the smaller number; the remainder then divides the previous divisor. The process is repeated till the remainder is zero. The divisor then result the GCD. 6. The annual examination result of 50 students in a class is tabulated as follow: Roll No. Subject A Subject B Subject C Write a program to read the data, calculate and display the following: 1. Average marks obtained by each student 2. Print the roll number and average marks of the students whose average mark is above 80. 3. Print roll numbers and average marks of the students whose average mark is below 40. ICSE questions [2010] 1. Write a program to perform binary search on a list of integers given below, to search for an element input by the user, if is fond display the element along with its position, otherwise display the message “Search element not found” 5, 7, 9, 11, 15, 20, 30, 45, 89, 97 2. Define a class Student described as below: Data members/instance variable: name, age, m1, m2, m3 (marks in 3 subjects), maximum, average Member Methods: (i) A parameterized constructor to initialize the data members (ii) To accept the details of a student (iii) To compute the average and the maximum out of three marks (iv) To display the name, age, marks in three subjects, maximum and average. Write a main method to create an object of a class and call the above member methods. 3. Shasha Travels Pvt. Ltd. Gives the following discount to its customers: Ticket Amount Discount Above Rs. 70000 18% Rs.55001 to Rs.70000 16% Rs.35001 to Rs.55000 12% Rs.25001 to Rs.35000 10% less than Rs.25001 2% Write a program to input the name and ticket amount for the customer and calculate the discount amount and net amount to be paid. Display the output in the following format for each customer: Sl. No. Name Ticket Charges Discount Net Amount -------- ------- ----------- --------- ---------- - (Assume that there are 15 customers, first customer is given the serial no. (Sl. No.) 1, next customer 2 … and so on) 4. Write a menu driven program to accept a number and check and display whether it is prime or not OR an automorphic number or not. (Use switch case statement) (a) Prime Number: A number is said to be a prime number if it is divisible only by 1 and itself and not by any other number. Example: 3, 5, 7, 11, 13 etc. (b) Automorphic Number: An Automorphic number is the number which is contained in the last digit(s) of its square. Example: 25 is an automorphic number as its square is 625 and 25 is present as the last two digits. 5. Write a program to store 6 elements in a array P, and 4 element in an array Q and produce a third array R, containing all the elements of array P and Q. Display the resultant array. Example: INPUT in P[ ] 4 6 1 2 3 10 and in Q[ ]19 23 7 8 OUTPUT R[ ]  4 6 1 2 3 10 19 23 7 8 6. Write a program to input a string in uppercase and print the frequency of each character. Example: INPUT COMPUTER HARDWARE OUTPUT: CHARACTER FREQUENCY A 2
  • 16. 16 C 1 D 1 E 2 H 1 M 1 O 1 P 1 R 3 T 1 U 1 W 1 ICSE Question [2011] 1. Define a class called Mo-bike with the following description: Instance variable/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 - to calculate and store the rental charges Member Methods: void input() - to input and store details of the customer void compute()- to compute the rental charges The rent for the mo-bike is charges on the following basis: First 5 days Rs.500 per day Next 5 days Rs.400 per day Rest of the days Rs.200 per day void display() - to display the details in the following format: Bike No Phone No. Name No. Of days Charge -------- ----------- ------------- ------------- ---------- 2. Write a program to input and store the weight of ten people. Sort and display them in descending order using the selection sort technique. 3. Write a program to input a number and print whether the number is a special number or not. 4. Write a program to accept a word and convert it to lowercase if it is in uppercase and display the new word by replacing only the vowels with the character following it. Example: Sample input : computer Sample output : cpmpvtfr 5. Design a class to overload a function compare ( ) as follows: 1. void compare ( int, int)- to compare two integer values and print the greater of the two integers. 2. void compare (char, char)- to compare the numeric value of two characters and print the character with higher numeric value. 3. void compare (String, String)- to compare the length of the two strings and print the longer of the two. 6. Write a menu driven program to perform the following: (Use switch – case statement) 1. To print the series 0, 3, 8, 15, 24 .. n terms (value of ‘n’ is to be an input by the user). 2. To find the sum of the series given below: S = ½ + ¾ + 5/6 + 7/8 + ............. + 19/20 ICSE Question [2012] 2. Define a class Called Library with the following description: Instance variable/data members: int acc_num - Stores the accession number of the book String title - stores the title of the book String Author - store the name of the author Member methods: i.Void input() -to input and store the accession number, title and author ii.Void compute () -To accept the number of days late, calculate and display the fine To be charged at Rs. 2 per day. iii.Void display To display the details in the following format: Accession Number Title Author Write a main method to create an object of the class and call the above member methods.
  • 17. 17 2. Given below is a hypothetical table showing rates of Income Tax for male citizens below the age of 65 years: Taxable Income (TI) in Rs. Income Tax in Rs. Does not exceed Rs. 1,60,000 Nil Is greater than Rs.1,60,000 & less than or equal to Rs.5,00,000 (TI – 1,60,000) x 10% Is greater than Rs.5,00,000 & less than or equal to Rs.8,00,000 [(TI – 5,00,000) x 20%] + 34,000 Is greater than Rs.8,00,000 [(TI – 8,00,000) x 30%] + 94,000 Write a program to input age, gender (male or female) and Taxable Income of a person. If the age is more than 65 or the gender in female, display “wrong category”. If the age is less than or equal to 65 years and the gender is male, compute and display the Income Tax payable as per the table given above. 3. Write a program to accept a string. Convert the string to uppercase. Count and output the number of double letter sequences that exist in the string. 4. Design a class to overload a function polygon () as follows: i.Void polygon (int n, char ch)-with one integer argument and one character type argument that draws a filled square of side n using the character stored in ch. ii.void polygon(int x, int y) -with two integer argument that draws a filled rectangle of length x and breadth y, using the symbol ‘@’. iii.void polygon () - with no argument that draws a filled triangle shown below * * * * * * 5. Using switch case statement, write a menu driven program to: i.Generate and display the first 10 terms of the Fibonacci series starting from 0. ii.Find the sum of the digits of an integer that is input For an incorrect choice an appropriate error message should be displayed. 6. Write a program to accept the names of 10 cities in a single dimension string array and their STD codes in another single dimension integer array. Search for a name of a city input by the user in the list. If found display “search successful” and print the name of the city along with its STD code, or else display the message “Search Unsuccessful, No such city in the list”. ICSE Question [2013] 1. Define a class named FruitJuice with following description: Instance variable/data Members: int product_code :Store the product code number String flaour :Store the flaour of the juice (E.g. Orange,apple etc.) String pack_type :Store the type of packaging (Eg. Tetra Pack, PET bottle etc.) int pack_size :Store packagr size (Eg. 200ml, 400ml etc) int product_price :Store the price of the product Member Methods: i. FruitJuice() :Default constructor to initialize integer data members to 0 and String data members to “”. ii. void input() :To input and store the product_code, flavour,pack_type, pack_size and product_price. iii. void discount() :to reduce the product_price by 10. iv. void display() :to display the product code, flavour, pack size and product price. 2. The international Standard Book Number (ISBN) is a unique numeric book identifier which is printed on every book. The ISBN is based upon a 10 digit code. The ISBN is legal if: 1*digit1 + 2*digit2 +3*digit3 + 4*digit4 + 5*digit5 + 6*digit6 +7*digit7 + 8*digit8 + 9*digit9 + 10*digit10 is divisible by 11. Example: for a ISBN 1401601499 1*1+ 2*4 +3*0 + 4*1 + 5*6 + 6*0 +7*1 + 8*4 + 9*9 + 10*9=253 which is divisible by 11. Write a program to: (i) input the ISBN code as 10 digit integer. (ii) If ISBN is not 10 digit integer, output the message, “Illegal ISBN and terminate the program. (iii) If the number is 10 digit do the calculation as shown above. (iv) If sum is divisible by 11, output message, “Legal ISBN”. If the sum is not divisible by 11 output the message “Illegal ISBN”.
  • 18. 18 3. Write a program that encodes a word into Pig latin. To translate a word into a Pig latin word, convert the word to Uppercase and then place the first vowel of the original word as the start of the new word along with the remaining alphabets. The alphabets present before the vowel being shifted towards the end followed by “AY”. Sample input (1) : London Output – ONDONLAY Sample input (2) : Olympics Output – OLYMPICSAY 4. Write a program to input 10 integer element in an array and sort them in descending order using the bubble sort technique. 5. Design a class to overload a function series() as follows: (i) double series(double n) with one double argument and returns the sum of the series, sum = 1/1+1/2+1/3+......+1/n (ii) double series(double a, double n) with two double arguments and returns the sum of t he series, sum = 1/a2+4/a5+7/a8+10/a11+ .......to n terms. 6. Using switch statement, write a menu driven program: (i) To check and display whether a number input by the user is a composite number or not (A number is said to be a composite, if it has one or more than one factor excluding 1 and the number itself. Example 4, 6, 8, 9 . . . . . . . (ii) To find the smallest digit of an integer that is input. Sample input : 6524 Sample output : Smallest digit is 2 For an incorrect choice, an appropriate error message should be displayed. ICSE Question [2014] Q 1: Define a class named movieMagic with the following desctription: 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 popularity rating of the movie (minimum rating = 0.0 and maximum rating = 5.0) Member methods: movieMagic() : default constructor to initialize numeric data members to o and String data members to “”. void accept() : to input and store year, title and rating. void display() : To display the title of the movie and the 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-hits 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 method. Q 2: A special two digit number is such that when the sum of its digits is added to the product of its digits, the result is equal to the original two digit number. Write a program to accept a two digit number. Add the sum of its digits to the product of its digits. If the value is equal to the number input, out the message “Special 2 digit number” otherwise output the message “Not a special 2 digit number”. Q 3: Write a program to assign a full path and file name as given below. Using library function extract and out put the file path, file name and file extension separately as shown: Input : C:UsersadminPicturesflower.jpg Output : Path: C:UsersadminPictures File name: flower Extension: jpg Q 4: Design a class to overload a function area() as follows: (i) double area(double a, double b, double c) with three arguments, returns the area of a scalene triangle using the formula: area = √s(s-a)(s-b)(s-c) where s = (a+b+c)/2 (ii) double area (int a, int b, int height) with three integer arguments, returns the area of a trapezium using the formula: area = ½ height(a+b) (iii) double area(double diagonal1, double diagonal2) with two double arguments, returns the area of a rhombus using the formula:
  • 19. 19 area = ½ (diagonal1 x diagonal2) Q 5: Using switch statement, write a menu driven program to calculate the maturity amount of a Bank Deposit. The user is given the following option: (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 x n x P x n(n+1)/2 x r/100 x 1/12 For an incorrect option, an appropriate error message should be displayed. Q 6: Write a program to accept the year of graduation from school as an integer value from the user. Using Binary Search technique on the sorted array of integers given below, output the message “Record exists” if the value input is located in the array. If not, output the message “Record does not exist”. {1982, 1987, 1993, 1996, 1999, 2003, 2006, 2007, 2009, 2010}