Skip to main content

Posts

Showing posts with the label java

Anagram Strings

PROGRAM: ANAGRAM STRINGS Two strings are anagram if they are written using same exact letters,ignoring space, punctuation and capitalization. Each letter should have the same count in both strings. For Example: Mary and Army are anagram of each other. SYNTAX: import java.io.*; class anagram {     public static void main(String args[])throws IOException     {         BufferedReader br=new BufferedReader(new InputStreamReader(System.in));         System.out.println("Enter Two Strings to check whether they are anagram or not");         String s1=br.readLine();         String s2=br.readLine();         String nstr="",ntr="";int count=0;         for(int i=0;i less than s1 length;i++)         {             if(Character.isLetter(s1.charAt(i)))           ...

Decimal To Binary

AJ Java Programs Program 9: To Convert Decimal Number into its binary equivalent. For Example: 12 binary equivalent 1100 Syntax: import java.io.*; class dec_to_bin { public static void main(String args[])throws IOException {     int decimal;     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));     System.out.println("Enter a biary Number");     decimal=Integer.parseInt(br.readLine());     int binary=0;     int power=0;         //while(binary.length()>0)     while(decimal>0)     {         int temp = decimal%2;         binary+=temp*Math.pow(10, power++);         decimal=decimal/2;     }     System.out.println(binary); }} Tested Ok Program If You Don't Understand anything or want any program please write your request in Comment Section And Please Like ...

String Palindrome

AJ Java Programs Program 8: String Palindrome: A String is said to be palindrome if  it conveys same meaning when read from front or back Example  MADAM, DAD, MALAYALAM etc Syntax: import java.io.*; class str_palin {     public static void main(String args[])throws IOException     {         BufferedReader br=new BufferedReader(new InputStreamReader(System.in));         String s,rev="";         System.out.println("Enter a string to reverse It");         s=br.readLine();         s.trim();         int l=s.length();         for(int i=l-1;i>=0;i--)         {             rev=rev+s.charAt(i);         }             if(s.equals(rev))             System.out.println("It is s...

Piglatin

AJ Java Programs Program 7: Piglatin When in a word first character is moved to last and "ay" is added to it it becomes Piglatin Lets See how to do it. Syntax: import java.io.*; class  piglatin { public static void main(String args[])throws IOException {      char ch;    String word="",str="";    int i;    String s;    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));    System.out.println("Enter a String");    s=br.readLine();    s=s.trim();    s=" "+s+" ";    for(i=1;i<s.length();i++)    {        ch=s.charAt(i);        if(ch!=' ')        word+=ch;        else if(s.charAt(i-1)!=' ')        {            StringBuffer sb=new StringBuffer(word); ...

BINARY TO DECIMAL

AJ Java Programs Program 2: Write a program to Convert Binary Number into a Decimal Equivalent Example: 11101 = 29 Syntax: import java.io.*; class bintodec //binary to decimal { public static void main(String args[])throws IOException {     String binary;     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));     System.out.println("Enter a biary Number");     binary=br.readLine();     int decimal=0;     int power=0;       //while(binary.length()>0)     while(binary.length()>0)     {         int temp = Integer.parseInt(binary.charAt((binary.length())-1)+"");         decimal+=temp*Math.pow(2, power++);         binary=binary.substring(0,binary.length()-1);     }     System.out.println(decimal); } } Tested Ok Program If You Don't Understand anything or want ...