 |
Raj Pauwaa |
Lives in : Mumbai, Maharashtra,
INDIA
|
|
|
|
|
|
|
|
Next Destination : Dubai
Life Goals : cyber security
|
|
|
hindi, english and gujrati
|
|
ICSE Prelims 2018 : Computer Applications (G. D. Somani Memorial School, Mumbai) |
|
import java.util.Scanner;
public class JavaProgram
{
public static void main(String[] input)
{
String str1, str2;
int len, len1, len2, i, j, found=0, not_found=0;
Scanner scan = new Scanner(System.in);
System.out.print("Enter First String : ");
str1 = scan.nextLine();
System.out.print("Enter Second String : ");
str2 = scan.nextLine();
len1 = str1.length();
len2 = str2.length();
if(len1 == len2)
{
len = len1;
for(i=0; i<len; i++)
{
found = 0;
for(j=0; j<len; j++)
{
if(str1.charAt(i) == str2.charAt(j))
{
found = 1;
break;
}
}
if(found == 0)
{
not_found = 1;
break;
}
}
if(not_found == 1)
{
System.out.print("Strings are not Anagram to Each Other..!!");
}
else
{
System.out.print("Strings are Anagram");
}
}
else
{
System.out.print("Both Strings Must have the same number of Character to be an Anagram");
}
}
}
raj_pauwaa
|
ICSE Prelims 2018 : Computer Applications (G. D. Somani Memorial School, Mumbai) |
|
import java.util.*;
public class MagicNumberCheck
{
public static void main(String args[])
{
Scanner ob=new Scanner(System.in);
System.out.println("Enter the number to be checked.");
int n=ob.nextInt();
int sum=0,num=n;
while(num>9)
{
sum=num;int s=0;
while(sum!=0)
{
s=s+(sum%10);
sum=sum/10;
}
num=s;
}
if(num==1)
{
System.out.println(n+" is a Magic Number.");
}
else
{
System.out.println(n+" is not a Magic Number.");
}
raj_pauwaa
|
|
|