Page 252 - CA_Blue( J )_Class10
P. 252
7. Write a program to input time in second from the main() method and using method time(int), convert it to hours, minutes and seconds.
8. Write a program to input a number in the main() method and print whether it is a Pronic number or not by using a method
boolean pronic(int). This method will return true if the number is Pronic else returns false. A Pronic number is a number that is
the product of two consecutive numbers. Say, 12 = 3 x 4.
9. Using the method int GCD(int , int), write a method to print the greatest common divisor of two numbers. Also, using the
method int LCM(int, int, int) to find the lowest common multiple of the two numbers.
GCM(int, int): will have parameters as two numbers.
LCM(int, int, int): will have parameters as two numbers and gcd of the two numbers.
10. Write a program to input the name and annual salary of an employee and using the method cal_tax(double), calculate the tax
according to the following criteria:
Annual Salary Tax
Up to Rs. 1,00,000 Nil
1,00,001 to 2,00,000 5% of the salary above 1,00,000
2,00,001 to 3,00,000 5,000+ 12% of the salary above 2,00,000
Above 3,00,000 7,000+15% of the salary above 3,00,000
11. Write a program to input the sales of a salesman and print the discount and discounted price according to the following criteria:
Sales Discount Rate
Above 10000 10%
6000 to 9999 8%
2000 to 5999 4%
<2000 no discount
Use the method void discount(double) to calculate discount and discounted price.
12. Write a program to input total number of units of electricity consumed and using the method void bill(int unit), calculate and
print the bill to be paid according to the following criteria:
Units Rate
First 100 units 5/- per unit
Next 150 units 8/- per unit
Next 200 units 10/- per unit
More than 5450 units 15/- per unit
13. Design a program having overloaded method area() to do the following:
a. void area (int, int) - to calculate and display the area of a rectangle
b. void area(int) - to calculate and display the area of a square
c. void area(double) - to calculate and display the area of a circle
14. Define a program having overload method Area() to do the following:
a. double Area (int b, int h) - to calculate the area of parallelogram (base x height)
b. double Area (double d1, double d2) - to calculate the area of rhombus (diagonal d1 x diagonal d2)
c. double Area (int a, int b, double h) - to calculate the area of trapezium (½ * (a + b) * h) - a and b are the parallel sides,
h is the perpendicular distance between the parallel sides.
The methods will return the return values to the main() method.
15. Write a program to create an overloading method to do the following:
a. void shape (int m, int n) - Prints a rectangle of m rows and n columns.
Say, Input m=3, n=4;
Output: xxxx
xxxx
xxxx
b. void shape (int s, char ch)
Say, Input s=4, ch= 'A'
Output: AAAA
AAAA
AAAA
AAAA
250250 Touchpad Computer Applications-X

