0% found this document useful (0 votes)
47 views5 pages

Take A Character Input From Key-Board, and Check It, Is It Alphabet With Vowel or Alphabet With Consonant, or Number, or Special Character

1) The document contains code to check if a number is an Armstrong number between 0 and 9999. It calculates the sum of the cubes of each digit and checks if it is equal to the original number. 2) The code takes a character input from the user and checks if it is a vowel, consonant, number or special character. 3) The code reverses a number by extracting each digit and adding it to the result multiplied by an appropriate place value. 4) The code calculates the factorial of a given number by multiplying it with all integers down to 1.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views5 pages

Take A Character Input From Key-Board, and Check It, Is It Alphabet With Vowel or Alphabet With Consonant, or Number, or Special Character

1) The document contains code to check if a number is an Armstrong number between 0 and 9999. It calculates the sum of the cubes of each digit and checks if it is equal to the original number. 2) The code takes a character input from the user and checks if it is a vowel, consonant, number or special character. 3) The code reverses a number by extracting each digit and adding it to the result multiplied by an appropriate place value. 4) The code calculates the factorial of a given number by multiplying it with all integers down to 1.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

Checking if a number is armstrong number

*/
public class ArmstrongBetween0To9999 {

public static void main!tring aga"#${
int num%
boolean isAmstrong&false%
int result&0%
int rem&0%
forint i&'%i(&9999%i))${
num&i%
whilenum*&'${
rem&num+'0%
result&rem*rem*rem$)result%
num&num/'0%
,
ifresult&&i${
!-stem.out.printlni)/ is an armstrong number/$%
,
result&0%
rem&0%
,
,
,
Take a character input from key-board, and check it , is it alphabet with vowel or alphabet with
consonant, or number,or special character
?
1
2
3
4
5

!
"
#
1$
11
12
13
14
15
1
1!
1"
1#
2$
import 0ava.io.*%
class 1dentif-ingChar
{
public static void main!tring"#
args$throws 1234ception
{
Buffered5eader br & new
Buffered5eadernew
1nput!tream5eader!-stem.in$$%
!-stem.out.print/3nter ur
characters 6 /$%
char num &
br.read7ine$.charAt0$%
ifnum *&8A8 99 num(&8:8$;;
num*&8a899 num(&8<8$$
{
!-stem.out.println/an
alphabets /$%
{


ifnum&&8a8;; num&&8e8;;
num&&8i8;; num&&8o8;; num&&8u8;;
num&&8A8;; num&&838;; num&&818;;
21
22
23
24
25
2
2!
2"
2#
3$
31
32
33
34
35
3
3!
%everse a number
?
1
2
3
4
5

!
import 0ava.util.!canner%
import 0ava.io.*%
public class 5everse{
public static void main!tring"#
args${
!canner input & new
!canner!-stem.in$%
!-stem.out.println/3nter a
number /$%
num&&828;; num&&8=8$
{
!-stem.out.println/
vowel/$%

,
else
{
!-stem.out.println/
consonants/$%

,
,
,
else ifnum &&8 8;; num&&8>8;;
num&&8?8;; num&&8@8;; num&&8A8;;
num&&8+8;; num &&898;; num&&8*8;;
num&&8B8$

{
!-stem.out.println/ special
characters/$%
,
else ifnum&&808;; num&&8'8;;
num&&8C8;; num&&8D8;; num&&8E8;;
num&&8F8;; num&&8G8;; num&&8H8;;
num&&898$
{
!-stem.out.println/ digits/$%

,

,

,
"
#
1$
11
12
13
14
15
1
1!
int num &
input.ne4t1nt$%
int rem%
int result&0%
whilenum*0${
rem & num+'0%
result & result * '0 )
rem%
num & num/'0%
,
!-stem.out.println/5everse
number is 6 /)result$%
,
,
&actorial of a number
?
1
2
3
4
5

!
"
#
1$
11
12
13
14
15
1
1!
1"
import 0ava.util.!canner%
public class Iactorial{

public static void main!tring args"#${
!canner input & new !canner!-stem.in$%
!-stem.out.println/3nter a number /$%
int num &input.ne4t1nt$%
long result & '%
whilenum*0${
result & result * num%
numJJ%
,

!-stem.out.println/Iactorial of Kiven no. is 6 /)result$%

,

,
'ow to check even or odd number?
?
1
class 3ven2dd
{
2
3
4
5

!
"
#
1$
11
12
13
14
15
public static void main!tring args"#$
{
int num & 1nteger.parse1ntargs"0#$%
ifnum + C && 0$
{
!-stem.out.println/num is even/$%
,

else

!-stem.out.println/number is odd/$%
,
,
heck a number prime or not
?
1
2
3
4
5

!
"
#
1$
11
12
13
14
15
1
1!
1"
1#
2$
21
22
23
24
package com.bullraider%

import 0ava.util.!canner%
import 0ava.io.*%

public class LrimeMo{
public static void main!tring"# args${
!canner input & new !canner!-stem.in$%
!-stem.out.println/3nter a number /$%
int num &input.ne4t1nt$%
int flag&0%

forint i&C%i(num%i))${

ifnum+i&&0$

{
flag & '%
break%
,
,

ifflag&&0$
!-stem.out.printlnnum)/ is a Lrime Mumber/$%
else
!-stem.out.printlnnum)/ is not a Lrime Mumber/$%

,
25
2
2!
2"
2#
3$

,
(rint fibonacci series between 1 to 1$$
like $ 1 1 2 3 5 " 13 21 34 55 "# 144
?
1
2
3
4
5

!
"
#
1$
11
12
13
14
public class Iibonaci {
public static void main!tring"# args$ {
int n' & 0N nC & 'N num%
!-stem.out.printn' ) / / )
nC ) / /$%

for int i & 0% i ( '00% i))$ {
num & nC ) n'%
!-stem.out.printnum ) / /$%
n' & nC%
nC & num%
,
,
,

You might also like