Nilotpal Ghosh
array programs
1 Answer(s)      a year and 5 months ago
Posted in : Java Beginners

write a program in java to input 10 numbers in an array and print out the Armstrong numbers from the set.

View Answers

December 15, 2011 at 4:34 PM


import java.util.*;
class  ArmstrongNumbers
{
    public static boolean find(int num){
        boolean isArmstrong=false;
        int n = num;
        int check=0,remainder;
        while(num > 0){
        remainder = num % 10;
        check = check + (int)Math.pow(remainder,3);
        num = num / 10;
        }
        if(check == n)
        isArmstrong=true;
        else
        isArmstrong=false;

        return isArmstrong;
    }
    public static void main(String[] args) 
    {
        Scanner input=new Scanner(System.in);
        System.out.println("Enter Numbers: ");
        int array[]=new int[10];
        for(int i=0;i<array.length;i++){
            array[i]=input.nextInt();
        }
        System.out.println("Armstrong Numbers are: ");
        for(int i=0;i<array.length;i++){
            if(find(array[i])){
                System.out.println(array[i]);
            }
        }

    }
}









Related Pages:
array programs
array programs  write a program in java to input 10 numbers in an array and print out the Armstrong numbers from the set.   import... Numbers: "); int array[]=new int[10]; for(int i=0;i<array.length
array programs
array programs  write a program in java to input 10 numbers in an array and print out the Armstrong numbers from the set.   import... Numbers: "); int array[]=new int[10]; for(int i=0;i<array.length
3 Java Programs for Beginners
3 Java Programs for Beginners  Write a program that prompts the user...[][] array = new int[11][11]; for (int i=1; i<array.length; i++) { for (int j=1; j<array[i].length; j++) { array[i][j] = i*j; System.out.print(" " + array[i
programs - Java Beginners
Java Array Programs  How to create an array program in Java?  Hi public class OneDArray { public static void main (String[]args){ int... information.http://www.roseindia.net/java/beginners/arrayexamples/java_array_usage.shtmlamar.
Java programs on students assesment
Java programs on students assesment  1) Write a Java program that reads the details of student and do the mark assessments. (i) Input the name... is 3. Use an array to store the marks of the three subjects. (Use any
programs - Java Beginners
double array in java  Please give me an example of double array in java.  Hi friend public class TwoDArray { public static void main(String[] args){ int[][] twoD = new int[8][4]; for (int i=0; i<twoD.length; i
programs - Java Beginners
three dimensional array programs  Example of three dimensional array program in Java.  Hi friend public class ThreeDArray { public static void main(String[] args) { int[][][] threeD = new int[5][4][3]; for (int i
java programs - Java Beginners
java programs  design a java interface for adt stack .develop two different classes that implement the interface one using array and another using linkedlist  Hi Friend, Try the following code: import java.lang.
java lab programs - Java Beginners
this interface, one using array and the other using linked-list. Provide necessary exception
java lab programs - Java Beginners
different classes that implement this interface, one using array and the other
Simple Java Programs
Simple Java Programs In this section we will discuss about the Java programs This section will describe you the various Java programs that will help you..., super keyword in Java, Java type casting example, Java array examples, Java
Programs in java
Programs in java  Hi, What are the best programs in java for a beginner? Thanks
php programs
php programs  10 programs on varibles
Collection of Large Number of Java Sample Programs and Tutorials
Collection of Large Number of Java Sample Programs and Tutorials Java...; Converting a Collection to an Array Here is the illustration for the conversion from the collection to an array
java programs
java programs  Why word "static" is used in java programs
Java: Programs
Java: Programs Kinds of Programs There are several types of programs that you can build in Java. Applications - Main programs that run independently... Interface (GUI). Applets - Programs downloaded over the Internet that run in Web pages
Java Programs
Java Programs  Hi, What is Java Programs? How to develop application for business in Java technology? Is there any tool to help Java programmer in development of Java Programs? Thanks
php programs
php programs  I need 15 programs on arithmetic operators with comments. Please help me
java programs
java programs  Explain types of Java programs. Also explain how to compile and run them.   Types of Java Programs: Standalone Applications Web Applications Enterprise Applications Console Application Web services
programs in java
programs in java  . I need an application for managing an educational institute. That application should provide the details of Students Courses Faculty Fee details etc.., pl z guide me how to write these programe
java programs
java programs  i need help in understanding the whole concept of the 13 java programs that i hav...here r de programs.. int i,j,m,n; m=Integer.parseInt(args [0]); n=Integer.parseInt(args [1]); System.out.print
java programs
java programs  A union B, transpose of matric, denomination of a given number i need java programs for this category?   Hi Friend, Transpose of matrix: import java.util.*; public class Transpose { public
in_array
in_array  in_array in php
is _array()
is _array()  is_array() in php   Hi Friend, This function is of Boolean type.It checks whether a variable is an array or not. Here is an example: <?php $yes = array('Hello', 'World'); echo is_array($yes) ? 'Array
is _array()
is _array()  is _array()   Hi Friend, This function is of Boolean type.It checks whether a variable is an array or not. Here is an example: <?php $yes = array('Hello', 'World'); echo is_array($yes) ? 'Array
Example to show Array exception in java
Example to show Array exception in java       Array Exception are the type of exception which  is usually thrown when the programmer tries to access an array index which
Array
Array  how can i use elements of an array in a circular form? that is if the searching of the element reach the last elements of the array, then it will start serching from the begining of the array
Array
Array  is it possible to define array like this..? int[] intArray = new int[] {4,5,6,7,8}; Explain...?   Yes, you can. Java Initialize Array
Array
Array  What if i will not declare the limit index of an array, how will I declare an array and store values with it using loop?   Hi Friend...(System.in); int array[]=new int[5]; System.out.println("Enter Array Elements
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
Array
Array  How do i insert elements into an array up to a limit from...("Enter Range: "); int size=input.nextInt(); int array[]=new int[size]; System.out.println("Enter Array Elements: "); for(int i=0;i<
array
array  WAP in java to store 6 element in array P and 4 element in array Q. Produce the third arra y R containing all element from p & q
Array
Array  can we create an array of size 1 lakh in java programming
array
array  array memory allocation is dynamic or static in java   Java Arrays have dynamic memory allocation
array
array  create an array in which no element is duplicate. if duplicate then tell to user duplicate. duplicacy is tell to user during when he enter the element

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.