0% found this document useful (0 votes)
26 views4 pages

Import Jav2

Uploaded by

prasadakshat07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views4 pages

Import Jav2

Uploaded by

prasadakshat07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

import java.util.

*;
public class Program9
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the value of n:");
int n=sc.nextInt();

int sumdig=sum(n);
int sumf=0;

int i=2;
while(n > 1)
{
if(n%i==0)
{ sumf=sumf + sum(i);
n= n/i;
}
else
{ if (i==2)
i=i+1;
else
i=i+2;
}
}
if(sumdig == sumf)
System.out.println("Smith Number");
else
System.out.println("Not A Smith Number");
}

public static int sum(int y)


{
int s=0;
while(y!=0)
{
int r=y%10;
s=s+r;
y=y/10;
}
return s;
}
}

import java.util.*;
public class program10
{ public static void main()
{ Scanner sc = new Scanner(System.in);
program10 ob = new program10();
System.out.println("Enter a number");
int n = sc.nextInt();
boolean b = ob.armstrong(n);
if(b==true)
System.out.println("Armstrong Number");
else
System.out.println("Not an Armstrong number");
}
boolean armstrong(int a)
{int copy = a;
int c=0;
while(copy> 0)
{ copy = copy/10;
c++;
}

int t=a;
int sum=0, d=0;
while(a> 0)
{ d= a%10;
sum = sum + (int)Math.pow(d,c);
a= a/10;
}
if(sum==t)
return true;
else
return false;

}
}

import java.util.*;
public class program11
{
public static void main(String args[])
{ Scanner sc = new Scanner(System.in);
System.out.println("Enter a string:");
String st = sc.nextLine();
st = st + " ";
String s1="", rev="";
for(int i=0; i<st.length(); i++)
{ char ch = st.charAt(i);
if (ch!=' ')
{ s1= s1+ch;
rev = ch + rev;
}
else
{ System.out.print(rev + " ");
rev= ""; s1="";
}
}
}
}

import java.util.*;
public class program12
{
public static void main(String args[])
{ Scanner sc = new Scanner(System.in);
System.out.println("Enter a string:");
String st = sc.nextLine();
st = st + " ";
String s1="", rev="";
for(int i=0; i<st.length(); i++)
{ char ch = st.charAt(i);
if (ch!=' ')
{ s1= s1+ch;
rev = ch + rev;
}
else
{ if(s1.equalsIgnoreCase(rev)== true)
System.out.println(s1);
rev= ""; s1="";
}
}
}
}

import java.util.*;
public class program13
{ public static void main(String args[])
{Scanner sc = new Scanner(System.in);
System.out.println("Enter a number");
int n= sc.nextInt();
String name[] = new String[n];
System.out.println("Enter " + n + " names");
for(int i=0; i<n; i++)
{ name[i] = sc.next();;
}
System.out.println("Names ending with a vowel");
for(int i=0; i<n; i++)
{ String s = name[i];
int l = s.length();
char ch = s.charAt(l-1);
if (ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U'
|| ch=='a'||ch=='e'||ch=='i'|| ch=='o'|| ch=='u')
System.out.println(name[i]);
}
}
}
import java.util.*;
public class program14
{ public static void main(String args[])
{ Scanner sc = new Scanner(System.in);
System.out.println("Enter a sentence:");
String s = sc.nextLine();
int ctr=0;

for (int i=0; i<s.length(); i++)


{ char ch = s.charAt(i);
if (ch=='A'|| ch=='E'||ch=='O'||ch=='I'||ch=='U'
||ch=='a'|| ch=='e' || ch=='o'||ch=='i' || ch=='u')
ctr = ctr + 1;
}
System.out.println("number of vowels =" + ctr);

}
}
import java.util.*;
public class program15
{ public static void main(String args[])
{Scanner sc = new Scanner(System.in);
System.out.println("Enter a number");
int n= sc.nextInt();
String name[] = new String[n];
System.out.println("Enter " + n + " names");
for(int i=0; i<n; i++)
{ name[i] = sc.next();
}
int ctr=0;
for(int i=0; i<n; i++)
{ char ch = name[i].charAt(0);
if (ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U'
|| ch=='a'||ch=='e'||ch=='i'|| ch=='o'|| ch=='u')
ctr=ctr+1;
}
System.out.println("No. of words starting with a vowel " + ctr);
}
}

You might also like