45 solutions available
Question 1What are loop control structures? What are the essential segments of a loop control structure?
Question 2How are these statements different from each other?i. breakii. continueiii. System.exit(0)iv. return
Question 3(i)Identify all the errors in the following statements.for (int i = 5; i > 0; i++) { System.out.println("Java is fun!"); }
Question 3(ii)Identify all the errors in the following statements.while (x < 1 && x > 50) { a = b; }
Question 3(iii)Identify all the errors in the following statements.while (x == y) { xx = yy; x = y; }
Question 4What is an empty statement? Explain its usefulness.
Question 5Convert the following for loop statement into the corresponding while loop and do-while loop:int sum = 0; for (int i = 0; i <= 50; i++)...
Question 6What are the differences between while loop and do-while loop?
Question 7(i)How many times are the following loop bodies repeated? What is the final output in each case?int x = 2; while (x < 20) if (x % 2...
Question 7(ii)How many times are the following loop bodies repeated? What is the final output in each case?int y = 2; while (y < 20) if (y % 2...
Question 7(iii)How many times are the following loop bodies repeated? What is the final output in each case?int z = 2; while (z < 20) if...
Question 9What is the output produced by the following code?int num = 20; while (num > 0) { num = num - 2; if (num == 4) break ;...
Question 10What is the output produced by the following code?int num = 10; while (num > 0) { num = num - 2; if (num == 2)...
Question 11Write a program to input n number of integers and find out:i. Number of positive integersii. Number of negative integersiii. Sum of...
Question 12Write a program using do-while loop to compute the sum of the first 500 positive odd integers.public class KboatSumOdd { public static...
Question 13Write three different programs using for, while, and do-while loops to find the product of series 3, 9, 12,... 30.public class KBoatSeries...
Question 14Write a program to convert kilograms to pounds in the following tabular format (1 kilogram is 2.2...
Question 15Write a program that displays all the numbers from 150 to 250 that are divisible by 5 or 6, but not both.public class KboatFactorCheck {...
Question 16Write 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...
Question 17Write a program in Java to read a number, remove all zeros from it, and display the new number. For example,Sample Input: 45407703Sample...
Question 18Write 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...
Question 19Write 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) +...
Question 20Write a program to display the following patterns as per the user's choice.Pattern 1 I C S E Pattern 2 I C S...
Question 21Write 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 For an...
Question 22Write 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...
Question 23Write 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...
Question 24Write 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...
Question 25Using the switch statement, write a menu driven program to:Generate and display the first 10 terms of the Fibonacci series 0, 1, 1, 2, 3,...
Question 26Write 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...
Question 27Write 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...
Question 28Write 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/20The output...
Question 29Write a program in Java to compute and display factorial of numbers up to a number entered via the Scanner class. The output should look...
Question 30(i)Write a program in Java to find the sum of the given series:x1 + x2 + x3 + x4 + ..... + xnimport java.util.Scanner; public class...
Question 30(ii)Write a program in Java to find the sum of the given series:x1 - x2 + x3 - x4 + ..... - xn , where x = 3import java.util.Scanner;...
Question 30(iii)Write a program in Java to find the sum of the given series:1x1+2x2+3x3+...+nxn\dfrac{1}{x^1} + \dfrac{2}{x^2} + \dfrac{3}{x^3} + ......
Question 30(iv)Write a program in Java to find the sum of the given series:12+23+34+...+4950\dfrac{1}{2} + \dfrac{2}{3} + \dfrac{3}{4} + ... +...
Question 30(v)Write a program in Java to find the sum of the given series:11+22+33+...+1010\dfrac{1}{\sqrt{1}} + \dfrac{2}{\sqrt{2}} +...
Question 30(vi)Write a program in Java to find the sum of the given series:x+13+x+25+x+37+...to n terms\dfrac{x + 1}{3} + \dfrac{x + 2}{5} + \dfrac{x...
Question 30(vii)Write a program in Java to find the sum of the given series:x2!+x3!+x4!+...+x20!\dfrac{x}{2!} + \dfrac{x}{3!} + \dfrac{x}{4!} + ... +...
Question 30(viii)Write a program in Java to find the sum of the given series:x22!+x33!+x44!+...+xnn!,where n = 10\dfrac{x^2}{2!} + \dfrac{x^3}{3!} +...
Question 30(ix)Write a program in Java to find the sum of the given series:1 + 3 + 7 + 15 + 31 + ..... + (220 - 1)public class KboatSeries {...
Question 30(x)Write a program in Java to find the sum of the given series:1 * 2 * 4 * 8 * ..... * 220public class KboatSeries { public static...
Question 31Write a menu driven class to accept a number from the user and check whether it is Palindrome or a Perfect number.Palindrome number: A...
Question 32Write 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...
Question 12How many times will the following loop execute?public static void main(String args[]) { int i = 1; while (i < 10) if...