study java

Bubble Sort in String Program in Java

Bubble Sort is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. This process is repeated until no more swaps are needed, which means the list is sorted.

Palindrome String

import java.util.Scanner; public class PalindromeString { public static void main(String[] args) { String st,revSt=””; int l; Scanner sc=new Scanner(System.in); System.out.print(“Enter String:”); st=sc.nextLine(); l=st.length(); for (int i = l-1; i >= 0; i–) { char ch; ch=st.charAt(i); revSt=revSt+ch; } if(st.equals(revSt)) { System.out.println(“Palindrome String”); } else { System.out.println(“Not Palindrome String”); } } } Output: Enter String:asdsa Palindrome […]

Piglatin Form Program in Java

Piglatin Form First, the vowels are checked and first occurring vowel in the word is found. Then, the Piglatin word is formed by taking the substring from first vowel position and then concatinating it with the letters from first letter till the first vowel i.e. before the first vowel.Finally a string “AY” is added at […]

Find Vowels And Capital Letter in Array Program in Java

import java.util.Scanner; public class FindVowelAndCapitalInArray { public static void main(String[] args) { int vowelCount=0, upperCaseCount = 0; char ar[] = new char[10]; Scanner sc = new Scanner(System.in); for (int i = 0; i < 10; i++) { System.out.print("Enter the number ar[" + i + "]:"); ar[i] = sc.next().charAt(0); } System.out.println("-------------------------------"); for (int i = 0; […]

Find Positive and Negative Numbers in Array Program in Java

import java.util.Scanner; public class FindPositiveAndNegative { public static void main(String[] args) { int ar[] = new int[10]; Scanner sc = new Scanner(System.in); for (int i = 0; i < 10; i++) { System.out.print("Enter the number ar[" + i + "]:"); ar[i] = sc.nextInt(); } System.out.println("The +ve numbers are:"); for (int i = 0; i < […]

Peterson Number Program in Java

A Peterson number (or a cyclic number) is a number where the sum of the factorials of its digits is equal to the number itself. For example, 145 is a Peterson number because 1!+4!+5!=1+24+120=1451!+4!+5!=1+24+120=145.

Mystery Number Program in Java

A number is called mystery number if the sum of two numbers and those two numbers should be the reverse of each other.

Print Capital String Program in Java

public class PrintCapitalString
{
public static void main(String[] args)
{

Fascinating Number Program in Java

Example: 327 Multiply with 2: 327×2=654 Multiply with 3: 327×3=981 Now, concatenate the all number. “327”+”654″+ “981”= 327654981 Here we can see that all digits from 1 to 9 are available in concatenating string. import java.util.Scanner; public class FascinatingNumber { public static void main(String args[]) { int num, num2, num3; Scanner sc = new Scanner(System.in); […]

Evil Number Program in Java

import java.util.Scanner; public class EvilNumber { public static void main(String[] args) { int n,num; Scanner sc = new Scanner(System.in); System.out.print(“Enter number=”); n = sc.nextInt(); int binaryDigits=0; String binary = “”; num=n; while (num > 0) { binary= num % 2 + binary ; if(num%2==1) { binaryDigits++; } num = num / 2; } if(binaryDigits%2==0) { […]

1 2 3 6