Enter 3 numbers from the user & make a function to print their average.
import java.util.*;
public class Solutions {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int average = (a + b + c) / 3;
System.out.println(average);
}
Write a function to print the sum of all odd numbers from 1 to n.
Write a function which takes in 2 numbers and returns the greater of those two.
Write a function that takes in the radius as input and returns the circumference of a circle.
Write a function that takes in age as input and returns if that person is eligible to vote or not. A person of age > 18 is eligible to vote.
Write an infinite loop using do while condition.
Write a program to enter the numbers till the user wants and at the end it should display the count of positive, negative and zeros entered.
Two numbers are entered by the user, x and n. Write a function to find the value of one number raised to the power of another i.e. x^n.
Write a function that calculates the Greatest Common Divisor of 2 numbers.
Write a program to print Fibonacci series of n terms where n is input by user :
0 1 1 2 3 5 8 13 21 .....
In the Fibonacci series, a number is the sum of the previous 2 numbers that came before it.
Take an array of names as input from the user and print them on the screen.
Find the maximum & minimum number in an array of integers.
[HINT : Read about Integer.MIN_VALUE & Integer.MAX_VALUE in Java]
Take an array of numbers as input and check if it is an array sorted in ascending order.
Eg : { 1, 2, 4, 7 } is sorted in ascending order.
{3, 4, 6, 2} is not sorted in ascending order.
Searching for an element x in a matrix.
Print the spiral order matrix as output for a given matrix of numbers.
For a given matrix of N x M, print its transpose in java.
Take an array of Strings input from the user & find the cumulative (combined) length of all those strings.
Input a string from the user. Create a new string called ‘result’ in which you will replace the letter ‘e’ in the original string with letter ‘i’.
Example :
original = “eabcdef’ ; result = “iabcdif”
Original = “xyz” ; result = “xyz”
Input an email from the user. You have to create a username from the email by deleting the part that comes after ‘@’. Display that username to the user.
email = “mejona@gmail.com” ; username = “mejona”
email = “helloWorld123@gmail.com”; username = “helloWorld123”
Reverse a String (using StringBuilder class) in java.
Write a function to multiply 2 numbers.
Write a function to calculate the factorial of a number.
Write a function to calculate the product of 2 numbers.