Write a menu-driven class that accepts a number from the user and checks whether it is a Palindrome or a Perfect number.This Java program allows users to check if a given number is a Palindrome or a Perfect number through a menu-driven interface, showcasing basic control structures and methods. Read more
Read Answer
i. Palindrome number : (A number from the user and check read in reverse order is same as in the right order).Example: 11, 101, 151, Atc. ii. 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 |
|||||||||||||||
Write a program to display the given pattern: 1 2 3 4 5, 2 2 3 4 5, 3 3 3 4 5, 4 4 4 4 5, 5 5 5 5 5This Java program generates a pattern where each row begins with incrementing integers followed by repetitions of the current row number, showcasing a combination of columns based on the current row. Read more
|
|||||||||||||||
Write a program in Java to display the given pattern 1 2 3 4 5 6 7, 1 2 3 4 5, 1 2 3, 1This Java program generates a decreasing number pattern where the first row starts with 7 numbers and each subsequent row reduces by 2 numbers until only 1 number is printed in the final row. Read more |
|||||||||||||||
Write a program to display the given pattern: 1, 2 3, 4 5 6 ,7 8 9 10 ,11 12 13 14 15This Java program displays a number pattern in which the numbers start from 1 and are arranged in a triangular fashion, with each row containing one more number than the previous row. The numbers are printed sequentially. Read more |
|||||||||||||||
Write a program in Java to find the sum of the given series S = 1/2 - 2/3 - 3/4 - ……… - 10/11This program calculates the sum of the series � = 1 2 − 2 3 − 3 4 − ⋯ − 10 11 S= 2 1 − 3 2 − 4 3 −⋯− 11 10 using a loop structure in Java. The result is displayed after calculating the total sum of the terms. Read more
|
|||||||||||||||
Write a program to find the sum of series, taking the value of ‘a’ and ‘n’ from the user. S = a+1/2 + a+3/4 + a+5/3 + ………… + to nHere is a Java program that calculates the sum of the series � = � + 1 2 + � + 3 4 + � + 5 3 + … S=a+ 2 1 +a+ 4 3 +a+ 3 5 +… up to n terms, where a and n are provided by the user: Read more
|
|||||||||||||||
Write a program to find the sum of series, taking the value of ‘a’ and ‘n’ from the user. S = a/1 + a/2 + a/3 + a/4 + ……… + a/nThis program calculates the sum of the series � = � 1 + � 2 + � 3 + … + � � S= 1 a + 2 a + 3 a +…+ n a , where 'a' and 'n' are provided by the user as input. It uses a loop to compute each term in the series and outputs the total sum. Read more
|
|||||||||||||||
Write a program In Java to find the sum of the series S = 1 + (1*2) + (1*2*3) + …………… + 10 termsThis Java program calculates the sum of the series � = 1 + ( 1 × 2 ) + ( 1 × 2 × 3 ) + ⋯ + 10 S=1+(1×2)+(1×2×3)+⋯+10 terms. It uses nested loops to compute the product of numbers for each term and then adds it to the running sum. Read more
|
|||||||||||||||
Write a program in Java to find the sum of the series S = 1+ 1/2 +1/3 + ……… +1/10This Java program calculates and displays the sum of the series � = 1 + 1 2 + 1 3 + . . . + 1 10 S=1+ 2 1 + 3 1 +...+ 10 1 . It uses a loop to compute the sum of the reciprocal values of the first ten natural numbers. Read more |
|||||||||||||||
Write a program in Java to display the first 10 numbers of the Fibonacci series 0, 1, 1, 2, 3, ………This Java program generates and displays the first 10 numbers of the Fibonacci series: 0, 1, 1, 2, 3, and so forth. It uses a simple loop to calculate each term based on the sum of the previous two terms. Read more
|
|||||||||||||||
Write a program in Java to display the first eight numbers of the series 1, 11, 111, 1111, 11111,...........This Java program generates and displays the first eight numbers of the series: 1, 11, 111, 1111, 11111, and so on. It uses a StringBuilder to construct each number iteratively and prints them to the console. Read more
|
|||||||||||||||
In a toss game, you want to know the number of times of getting ‘Head’ and ‘Tail’.This Java program simulates tossing a coin 20 times, tracking the number of times "Head" (1) and "Tail" (0) appear. It uses random number generation to simulate the tosses and displays the counts after completion. Read more
Read Answer
|
|||||||||||||||
You want to calculate the sum of all positive even numbers and the sum of all negative odd numbers from a set of numbers.This Java program takes a set of numbers from the user and calculates the sum of all positive even numbers and the sum of all negative odd numbers. The program uses loops and conditional statements to determine the sums based on user input. Read more
Read Answer
|
|||||||||||||||
Write a program in Java to accept 10 different numbers and display the greatest and the smallest of the numbers.This Java program allows users to input 10 different numbers and then determines and displays the greatest and smallest numbers among them. The program demonstrates the use of arrays, loops, and conditional statements in Java. Read more
Read Answer
|
|||||||||||||||
Write a program in Java to accept a number and check whether a number is perfect or not.Here's a Java program that accepts a number from the user and checks whether it is a perfect number or not. A perfect number is defined as a positive integer that is equal to the sum of its proper divisors, excluding itself. Read more
A number is said to be perfect if sum of the factors (including 1 and excluding the number itself) is the same as the original number Example: Input: 6 is a perfect number, Factors of 6 = 1, 2, 3: Thus, 6 = 1 + 2 + 3, is a perfect number. |
|||||||||||||||
Write a program to accept a number and check whether the number is prime or not.This program checks if a given number is prime: It accepts an integer input from the user. The checkPrime method determines if the number is prime by checking for factors from 2 up to the square root of the number. The program prints whether the number is prime or not. Read more
Read Answer
Write a program to accept a number and check
whether the number is prime or not.
|
|||||||||||||||
Write a program in Java to accept two numbers and find the Greatest Common Divisor (G.C.D.) of the two numbers.This Java program prompts the user to input two numbers and calculates their Greatest Common Divisor (G.C.D.) using the Euclidean algorithm. The G.C.D. is displayed as the output. Read moreWrite a program in Java to accept two numbers
and find the Greatest Common Divisor (G.C.D.) of the two numbers. |
|||||||||||||||
Write a program in Java to find the sum of any ten natural numbers.This Java program prompts the user to input ten natural numbers and calculates their sum. It ensures that only natural numbers (greater than zero) are accepted. The program then displays the total sum of the entered numbers. Read more
Read Answer
|
|||||||||||||||
Write a program based on the above criteria, to input a name, address, amount of purchase and the type of purchase (‘L’ for Laptop and ‘D’ for Desktop).Here is a Java program based on the seasonal discount criteria for purchasing a Laptop or Desktop PC from an electronics shop. Read more
|
|
Category |
Discount on Laptop |
Discount on Desktop PC |
|
Up to Rs. 25,000 |
0.0% |
5.0% |
|
Rs. 25,001 to Rs. 57,000 |
5.0% |
7.5% |
|
Rs. 57,001 to Rs. 1,00,000 |
7.5% |
10.0% |
|
More than Rs. 1,00,000 |
10.0% |
15.0% |
Write a program based on the above criteria, to input a name, address, amount of purchase and the type of purchase (‘L’ for Laptop and ‘D’ for Desktop). Compute and print the net amount to be a customer with his name and address.
Read Answer
This Java program calculates the depreciated value of a car based on its showroom price and the number of years it has been used. It uses a switch-case structure to determine the applicable depreciation rate and calculates the depreciated value. The program then displays the original price, depreciated value, and the amount to be paid for the car.
Read more|
No. of years used |
Rate of depreciation |
|
1 |
10% |
|
2 |
20% |
|
3 |
30% |
|
4 |
50% |
|
Above 4 years |
60% |