Write a java program to check Armstrong Number?
import java.util.*;
class ArmstrongNumber
{
public static void main(String args[])
{
int n=,sum=0,temp,r;
Scanner in=new Scanner(System.in);
System.out.println("Enter a number to check if it is an armstrong number");
n=in.nextInt();
temp=n;
while(temp!=0)
{
r=temp%10;
sum=sum+r*r*r;
}
if(n=sum)
System.out.println("Entered number is an armstrong number");
else
System.out.println("Entered number is not an armstrong number");
}
}
earn money online earn money earn money survey earn money from home earn money typing earn money at home photoshop tutorial web site design tutorial free web design tutorial c tutorial java program programming language jdk in java bloger help monteize blog OUTPUT
Write a java program to print Factorial Number?
import java.util.Scanner;
public class Factorial
{
public static void main(String args[])
{
int fact=1;
int number=0;
System.out.println("Enter a number to its factorial ");
Scanner in=new Scanner(System.in);
number=in.nextInt();
for(int i=1;i<=number;i++)
{
fact=i*fact;
}
System.out.println("the factorial of "+number+"is"+fact);
}
}
Write a Java program to print Fibonacci Series?
import.java.io.*;
import.java.lang.*;
class Fibonacii
{
public static void main(String args[])
{
int n1=0,n2=1,n3,i,count=10;
System.out.println(n1+" "+n2);//printing 0 and 1
for(i=2;i<count;i++)
{
n3=n1+n2;
System.out.print(" "+n3);
n1=n2;
n2=n3;
}
}
}
OUTPUT
Write a java program to print given number is even or odd ?
import.java.util.Scanner;
class OddOrEven
{
public static void main(String args[])
{
int a;
System.out.println("Enter an integer to check if it is even or odd");
Scanner in=new Scanner(System.in);
X=in.nextInt();
if(a%2 == 0)
System.out.println("You entered number is even")
else
System.ou.println("You entered number is Odd");
} }
OUTPUT
import java.util.*;
class ArmstrongNumber
{
public static void main(String args[])
{
int n=,sum=0,temp,r;
Scanner in=new Scanner(System.in);
System.out.println("Enter a number to check if it is an armstrong number");
n=in.nextInt();
temp=n;
while(temp!=0)
{
r=temp%10;
sum=sum+r*r*r;
}
if(n=sum)
System.out.println("Entered number is an armstrong number");
else
System.out.println("Entered number is not an armstrong number");
}
}
earn money online earn money earn money survey earn money from home earn money typing earn money at home photoshop tutorial web site design tutorial free web design tutorial c tutorial java program programming language jdk in java bloger help monteize blog OUTPUT
Write a java program to print Factorial Number?
import java.util.Scanner;
public class Factorial
{
public static void main(String args[])
{
int fact=1;
int number=0;
System.out.println("Enter a number to its factorial ");
Scanner in=new Scanner(System.in);
number=in.nextInt();
for(int i=1;i<=number;i++)
{
fact=i*fact;
}
System.out.println("the factorial of "+number+"is"+fact);
}
}
Write a Java program to print Fibonacci Series?
import.java.io.*;
import.java.lang.*;
class Fibonacii
{
public static void main(String args[])
{
int n1=0,n2=1,n3,i,count=10;
System.out.println(n1+" "+n2);//printing 0 and 1
for(i=2;i<count;i++)
{
n3=n1+n2;
System.out.print(" "+n3);
n1=n2;
n2=n3;
}
}
}
OUTPUT
Write a java program to print given number is even or odd ?
import.java.util.Scanner;
class OddOrEven
{
public static void main(String args[])
{
int a;
System.out.println("Enter an integer to check if it is even or odd");
Scanner in=new Scanner(System.in);
X=in.nextInt();
if(a%2 == 0)
System.out.println("You entered number is even")
else
System.ou.println("You entered number is Odd");
} }
OUTPUT
0 comments:
Post a Comment