Skip to content

Commit

Permalink
day 6 (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spreeha authored and MadhavBahl committed Dec 28, 2018
1 parent 141e528 commit 2a08749
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 0 deletions.
47 changes: 47 additions & 0 deletions day6/Java/anagrams.java
@@ -0,0 +1,47 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication3;

/**
*
* @author SPREEHA DUTTA
*/
import java.util.*;
public class anagrams {
public static String sort(String s)
{
char arr[]=s.toCharArray();
char b;
for(int i=0;i<arr.length;i++)
{
for(int j=1;j<arr.length-i;j++)
{
if(arr[j]<arr[j-1])
{
b=arr[j];
arr[j]=arr[j-1];
arr[j-1]=b;
}
}
}
s=new String(arr);
return s;
}
public static void main(String []args)
{
String s1,s2;
Scanner sc=new Scanner(System.in);
System.out.println("Enter two strings ");
s1=sc.next();
s2=sc.next();
s1=sort(s1);
s2=sort(s2);
if(s1.equals(s2))
System.out.println("They are anagrams");
else
System.out.println("They are not anagrams");
}
}
34 changes: 34 additions & 0 deletions day6/Java/capitalise.java
@@ -0,0 +1,34 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication3;

/**
*
* @author SPREEHA DUTTA
*/
import java.util.*;
public class capitalise {
public static void main(String []args)
{
String s;int i,j;char b;String str="";
Scanner sc=new Scanner(System.in);
System.out.println("Enter a string");
s=sc.nextLine();
String arr[]=s.split(" ");
for(i=0;i<arr.length;i++)
{
str="";
for(j=0;j<arr[i].length();j++)
{
b=arr[i].charAt(j);
if(j==0)
b=Character.toUpperCase(b);
str=str+b;
}
System.out.print(str+" ");
}
}
}
1 change: 1 addition & 0 deletions day6/Java/dailycodebase
Submodule dailycodebase added at 5462d0
33 changes: 33 additions & 0 deletions day6/Java/reverse_word.java
@@ -0,0 +1,33 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication3;

/**
*
* @author SPREEHA DUTTA
*/
import java.util.*;
public class reverse_word {
public static void main(String []args)
{
Scanner sc=new Scanner(System.in);
String s;int i,j;String str="";char b;

System.out.println("Enter a string ");
s=sc.nextLine();
String arr[]=s.split(" ");
for(i=0;i<arr.length;i++)
{
str="";
for(j=0;j<arr[i].length();j++)
{
b=arr[i].charAt(j);
str=b+str;
}
System.out.print(str+" ");
}
}
}

0 comments on commit 2a08749

Please sign in to comment.