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.

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 Tutorials/Questions & Answers:
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
Advertisements
programs
programs  give some programs on control statementds
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
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... Scanner(System.in); int array[]=new int[5]; System.out.println("Enter
Programs in java
Programs in java  Hi, What are the best programs in java for a beginner? Thanks
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
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
array
array  take a 2d array and display all its elements in a matrix fome using only one for loop and ple explain the program in below
array
accepts a pointer to integer which represents an array of integer.After that this method prints the entire of the array numbers to the monitor. include using std::cout; using std::endl; void printArray(int *array, int count
array
array  How to store the results of mysql query in an array... qurey in array: "select distinct(EMPLID)from tblwork where EMPLID not in (select... store the result in array
array
array  wap to calculate reverse of 10 elements in an array?  ...(); } System.out.print("Array is: "); for(int i=0;i<arr.length;i...(); System.out.print("After reversing, Array is: "); for(int i=arr.length-1;i>=0
php programs
php programs  10 programs on varibles
Array's
Array's  I have to finish an "order page". that checks 2 dropdown boxes and a set of radio buttons and put the results into a set of textboxes, 1 line at a time, then calculate a total. I know I need to create an array, but I'm
array
array  Hi i have array like {1,2,3,4,,5,5,6,6} then how can i... is an example that store some integers into an array and find the occurrence of each number from the array. import java.util.*; public class SearchNumberOccurrence
array
array  how to getting values and storing values in array by using datainputstream?   Hi Friend, Try the following code:ADS_TO_REPLACE_1...("Array Elements are: "); for(int i=0;i<arr.length;i
Array
reserved. Use a one-dimensional array of primitive type Boolean to represent the seating chart of the cinema theater. Initialize all the elements of the array... the corresponding elements of the array to true to indicate that the seat is no longer
java programs
java programs  Why word "static" is used in java programs
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
programs
programs
c++ programs
c++ programs  i want the syntax for the following programs according to c++ pattern. 1.sum of multiples of an integer upto 10 2.2/4+4/6+6/8+8/10+.....n/n+2 3.1!/1+2!/2+3!/3+4!/4+...n!/n i just want the main logic as i m nt
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
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
PHP Push Array to Array
PHP Push Array to Array  array_push() function using array in PHP
JSF Sample Programs
JSF Sample Programs  I need a JSF sample programs
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
how to execuite java programs???
how to execuite java programs???  I have jdk 1.6 installed in my pc.i want to execuite java programs in ms-dos for applet and without using applet.please tell me
how to execuite java programs???
how to execuite java programs???  I have jdk 1.6 installed in my pc.i want to execuite java programs in ms-dos for applet and without using applet.please tell me
Explain types of java programs
Explain types of java programs  Explain types of java programs   Types of Java Programs: Standalone Applications Web Applications Enterprise Applications Console Application Web services
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks

Ads