- Home
- Chapter 1 - Object Oriented Programming Concepts
- Object Oriented Programming Concepts
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 2 - Introduction to Java
- Introduction to Java
- Multiple Choice Questions
- Assignment Questions
- Chapter 3 - Values and Data Types
- Values and Data Types
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 4 - Operators in Java
- Operators in Java
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 5 - User-Defined Methods
- User-Defined Methods
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 6 - Input in Java
- Input in Java
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 7 - Mathematical Library Methods
- Mathematical Library Methods
- Multiple Choice Questions
- Assignment Questions
- Chapter 8 - Conditional Constructs in Java
- Conditional Constructs in Java
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 9 - Iterative Constructs in Java
- Iterative Constructs in Java
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions and Programs
- Chapter 10 - Nested for loops
- Nested for loops
- Assignment Questions and Programs
- Chapter 11 - Constructors
- Constructors
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 12 - Library Classes
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 13 - Encapsulation and Inheritance
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 14 - Arrays
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 15 - String Handling
- Library Classes
- Multiple Choice Questions
- Assignment Questions
Iterative Constructs in Java
Chapter 9
Iterative Constructs in Java
Class 10 - Logix Kips ICSE Computer Applications with BlueJ
![]() Share with a Friend |
Assignment Questions and Programs
- 1. Assignment Questions and Answers
11. Write a program to input n number of integers and find out:
i. Number of positive integers
ii. Number of negative integers
iii. Sum of positive numbers
iv. Product of negative numbers
v. Average of positive numbers
12. Write a program using do-while loop to compute the sum of the first 500 positive odd integers.
13. Write three different programs using for, while, and do-while loops to find the product of series 3, 9, 12,... 30.
14. Write a program to convert kilograms to pounds in the following tabular format (1 kilogram is 2.2 pounds):
Kilograms
Pounds
1
2.2
2
4.4
20
44.0
15. Write a program that displays all the numbers from 150 to 250 that are divisible by 5 or 6, but not both.
16. Write a program in Java to read a number and display its digits in the reverse order. For example, if the input number is 2468, then the output should be 8642.
Output:
Enter a number: 2468
Original number: 2468
Reverse number: 864217. Write a program in Java to read a number, remove all zeros from it, and display the new number. For example,
Sample Input: 45407703
Sample Output: 45477318. Write a program to read the number n using the Scanner class and print the Tribonacci series: 0, 0, 1, 1, 2, 4, 7, 13, 24, 44, 81 . . . and so on.
Hint: The Tribonacci series is a generalisation of the Fibonacci sequence where each term is the sum of the three preceding terms.19. Write a program to calculate the value of Pi with the help of the following series:
Pi = (4/1) - (4/3) + (4/5) - (4/7) + (4/9) - (4/11) + (4/13) - (4/15) ...
Hint: Use while loop with 100000 iterations.20. Write a program to display the following patterns as per the user's choice.
Pattern 1
I
C
S
E
Pattern 2
I
C
S
E
21. Write a menu-driven program to display the pattern as the per user's choice:
Pattern 1
ABCDE
ABCD
ABC
AB
A
Pattern 2
B
LL
UUU
EEEE
22. Write a program to input a number and check and print whether it is a Pronic number or not. (Pronic number is a number which is the product of two consecutive integers.)
Example: 12 = 3 x 4
20 = 4 x 5
42 = 6 x 723. Write a program to accept a number and check and display whether it is a spy number or not. (A number is called a spy number if the sum of its digits equals the product of the digits.)
Example:
Consider the number 1124.
Sum of the digits = 1 + 1 + 2 + 4 = 8.
Product of the digits = 1 * 1 * 2 * 4 = 8.24. Write a program to accept a number and check and display whether it is a Niven number or not. (Niven number number which is divisible by the sum of its digits).
Example:
Consider the number 126.
Sum of its digits is 1 + 2 + 6 = 9 and 126 is divisible by 9.25. Using the switch statement, write a menu driven program to:
- (1). Generate and display the first 10 terms of the Fibonacci series 0, 1, 1, 2, 3, 5.... The first two Fibonacci numbers are 0 and 1, and each subsequent number is the sum of the previous two.
- (2). Find the sum of the digits of an integer that is input.
Sample Input: 15390
Sample Output: Sum of the digits = 18
For an incorrect choice, an appropriate error message should be displayed.
26. Write a menu driven program to accept a number and check and display whether (i) it is a Prime Number or not (ii) it is an Automorphic Number or not. (Use switch-case statement).
- (i). 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.
- (ii). 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.
27. 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 to print the GCD of them.
- (1). A BUZZ number is the number which either ends with 7 or is divisible by 7.
- (2). GCD (Greatest Common Divisor) of two integers is calculated by continued division method. Divide the larger number by the smaller; the remainder then divides the previous divisor. The process is repeated till the remainder is zero. The divisor then results the GCD.
28. Write a program to read the number x using the Scanner class and compute the series:
Sum = x/2 + x/5 + x/8 + x/11+ ..... + x/20
The output should look like as shown below:
Enter the value of x: 10
Sum of the series is: 10.96161191749426929. Write a program in Java to compute and display factorial of numbers up to a number entered via the Scanner class. The output should look like as shown below when 7 is input.
Enter a number: 7
1! (=1) = 1
2! (= 1 x 2) = 2
3! (= 1 x 2 x 3) = 6
4! (= 1 x 2 x 3 x 4) = 24
5! (= 1 x 2 x 3 x 4 x 5) = 120
6! (= 1 x 2 x 3 x 4 x 5 x 6) = 720
7! (= 1 x 2 x 3 x 4 x 5 x 6 x 7) = 504030 (i). Write a program in Java to find the sum of the given series:
x1 + x2 + x3 + x4 + ..... + xn
30(ii). Write a program in Java to find the sum of the given series:
x1 - x2 + x3 - x4 + ..... - xn , where x = 3
30(iii). Write a program in Java to find the sum of the given series:
\[ \frac{1}{x^{1}} + \frac{2}{x^{2}} + \frac{3}{x^{3}} + \cdots + \frac{n}{x^{n}} \]
30(iv). Write a program in Java to find the sum of the given series:
\[ \dfrac{1}{2} + \dfrac{2}{3} + \dfrac{3}{4} + ... + \dfrac{49}{50} \]30(v). Write a program in Java to find the sum of the given series:
\[ \dfrac{1}{\sqrt{1}} + \dfrac{2}{\sqrt{2}} + \dfrac{3}{\sqrt{3}} + ... + \dfrac{10}{\sqrt{10}} \]30(vi). Write a program in Java to find the sum of the given series:
\[ \dfrac{x + 1}{3} + \dfrac{x + 2}{5} + \dfrac{x + 3}{7} + ...\text{to n terms} \]30(vii). Write a program in Java to find the sum of the given series:
\[ \dfrac{x}{2!} + \dfrac{x}{3!} + \dfrac{x}{4!} + ... + \dfrac{x}{20!} \]30(viii). Write a program in Java to find the sum of the given series:
\[ \dfrac{x^2}{2!} + \dfrac{x^3}{3!} + \dfrac{x^4}{4!} + ... + \dfrac{x^n}{n!}, \text{where n = 10} \]30(ix). Write a program in Java to find the sum of the given series:
1 + 3 + 7 + 15 + 31 + ..... + (220 - 1)
30(x). Write a program in Java to find the sum of the given series:
1 * 2 * 4 * 8 * ..... * 220
-
31. Write a menu driven class to accept a number from the user and check whether it is 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
-
32. 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 n numbers entered by the user. The program terminates when the user enters a zero.
