Write a program in Java to accept a String from the user. Pass the String to a function Display (String str) which displays the consonants present in the StringThis Java program takes a string input from the user and displays all the consonants present in that string, one per line. The program ensures case-insensitivity and skips vowels. Read more
Read Answer
p t r |
Write a class with the name Perimeter using function overloading that computes the perimeter of a square, a rectangle and a circle.This Java program uses function overloading to calculate the perimeter of a square, rectangle, and circle. It accepts user input for the relevant dimensions and computes the perimeter for each shape accordingly. Read more
Perimeter of a circle = 2*π*r |
Write a class with the name Area using function overloading that computes the area of a parallelogram, a rhombus and a trapezium.This Java program uses function overloading to calculate the area of a parallelogram, rhombus, and trapezium. The program takes user input for the relevant dimensions of each shape and computes the area accordingly. Read more
Formula:
Area of a parallelogram (pg) = b*h |
Write a program in Java using the method Discount( ), to calculate a single discount or a successive discount.This Java program calculates single or successive discounts on the printed price of an article using overloaded methods. It computes the final price based on user input and displays the amount to be paid. Read more
= Rs. (12000-1200) = Rs. (10800-864) Amount to be paid = Rs.9936 |
A Palindrome is a string that reads the same from the left to right and vice versa.This Java program uses a method to determine if a string is a palindrome. It checks whether the string reads the same forwards and backwards and provides the result. Read more
|
Write a program using a function called area ( ) to compute the area of aThis Java program computes the area of a circle, square, or rectangle based on the user's choice. It uses functions to calculate the areas and displays a menu for easy selection. Read more
a) circle (π*r²) where π = 3.14 |
Define a function int prime (int x) to check whether a number is prime or not. It returns 1 if the number is prime, O otherwise.This Java program accepts 10 integers in an array, uses a custom function to determine whether each number is prime, and prints all prime numbers in the array. Read moreWrite a program
in Java to accept 10 numbers in an array. Define a function int prime (int x)
to check whether a number is prime or not. It returns 1 if the number is prime,
O otherwise. Use the function to check and print all the prime numbers of the
array. |
Write a program in Java to accept 10 numbers in a Single Dimensional Array Pass the array to a function swap (int a[]) to interchange the numbers in such a way that a[0] is interchanged with 3a[1], a[2] with a[3] and so on.This Java program accepts 10 integers in an array, interchanges numbers using a custom swapping logic (a[0] with 3 * a[1], a[2] with a[3], etc.), and prints the updated array. Read moreWrite a program
in Java to accept 10 numbers in a Single Dimensional Array Pass the array to a
function swap (int a[]) to interchange the numbers in such a way that a[0] is
interchanged with 3a[1], a[2] with a[3] and so on. Finally print all the
numbers of the array. |
Write a program in Java to input a string using upper and lower case characters. Pass the string to a function lower (String x) to print only lower case letters.This program extracts and prints only the lower case letters from a mixed-case string provided by the user. Read moreWrite a program
in Java to input a string using upper and lower case characters. Pass the
string to a function lower (String x) to print only lower case letters. |
If two letters are consecutive in any position the function prints "It is a magic string" otherwise prints "It is not a magic string".This Java program checks if a word contains consecutive letters in the alphabet using the magic(String x) function. Read moreWrite a program in Java to accept a word. Pass
it to a function magic (string x) The function checks the string for the
presence of consecutive letters. If two letters are consecutive in any position
the function prints "It is a magic string" otherwise prints "It
is not a magic string". |
Write a Java program to accept a string. Pass it to a function freq (String x). the function finds and prints the frequency of each vowel.This Java program accepts a string and calculates the frequency of each vowel (A, E, I, O, U) in the string using the freq() function. Read moreWrite a Java
program to accept a string. Pass it to a function freq (String x). the function
finds and prints the frequency of each vowel. |
Write a function fact (int n) to find the factorial of a number n. include a main class to find the value of S where:This Java program computes the value of � S based on the formula � = � ! � ( � − � ) ! S= m(n−m)! n! , where the factorial of a number is calculated using the fact() function. Read more
|
Use a function int Armstrong(int n) to receive the number. The function returns 1 if the number is Armstrong otherwise 0.This Java program checks if a given number is an Armstrong number or not. It uses a function Armstrong(int n) to perform the check and return 1 if the number is Armstrong, otherwise 0. Read moreWrite a Java
program to input a number. Use a function int Armstrong(int n) to receive the
number. The function returns 1 if the number is Armstrong otherwise 0. |
Use a function daysofweek(int dysno) to accept the day number from the main class.This Java program accepts a day number (between 1 and 7) from the user and uses a switch-case statement to print the corresponding day of the week. Read moreWrite a program
in Java to input the day number. Use a function daysofweek(int dysno) to accept the
day number from the main class. The function uses a switch-case statement to print
the corresponding day of the week. |
Write a Java program to input the sides of a triangle.This Java program accepts the lengths of the three sides of a triangle from the user and checks whether the triangle is equilateral, isosceles, or scalene based on the values of the sides. Read moreWrite a Java
program to input the sides of a triangle. Pass the sides to a function decide (int
x, int y, int z) which checks and prints whether the triangle is equilateral,
isosceles or scalene. |
Write a program in Java to input 10 numbers. Use a function to find and print the cube of each number.This Java program accepts 10 numbers from the user and then uses the printCube() function to calculate and print the cube of each number. Read moreWrite a program in Java to input 10 numbers. Use
a function to find and print the cube of each number. |
The function will find whether the given element is the list or not. It returns true if found, false otherwise i.e. Boolean return type.This Java program accepts 10 numbers, and a search number, then checks if the search number exists in the array. It uses the search() function which returns a boolean value (true if the number is found, false otherwise). Read more
Read Answer
|
Write a program in Java to accept 10 numbers in S.D.A and pass all array to a function.This Java program accepts 10 numbers, performs binary search to find a specific number, and displays whether the number is present or not in the sorted array. Read more
Read Answer
|
Arrange all the numbers in ascending order.This Java program sorts a set of 10 numbers entered by the user in ascending order. It uses a sort() method to implement the sorting logic and then displays the sorted numbers. Read moreWrite
a program in Java to accept 10 numbers in Single Dimensional Array. Pass the
array to the function sort (int m[]). Arrange all the numbers in ascending
order. |
Design a class to overload a function num_cal ( ) as follows:This program demonstrates function overloading in Java by implementing multiple versions of the num_cal() method that perform different tasks based on the input arguments: computing squares/cubes, computing sums/products of integers, and comparing two strings. Read more
a) Void num_cal (int num, char ch) with one integer argument and one character argument. It computers the square of an integer if choice ch is ‘s’ otherwise, it computers its cube. |