Respuesta :

Answer:

The following program is written s=usinh java programming language;

Because of the length of the program, comments are used to explain some lines. So, you have to pay attention to the comments too.

public class Armstrong0_500

{

public static void main(String [] args)

{

 //Declare and initialize num variable to 0

 int num = 0;

 //Call Armstrong method

 Armstrong(num);  

}

//Define Armstrong method

public static boolean Armstrong(int num)

{

 //This is the heading

 System.out.println("Armstrong Numbers\t\tDifference between Successive Armstrong Numbers");

 int nums; //This is used to represent digits from 0 to 500

 //Initialize old_Arms and new_Arms to 0

 int old_Arms =0; int new_Arms = 0;

 //Initialize counter

 int count = 0;

 while(count<=500)

 {

 nums = count;

 //The next variables are useful;

 //temp is used to store temporary values

 //value is used to store the cube of individual integer that makes up a number

 //remain is used to store remainder after division

 int remain;

 int temp;

 int value = 0;

 temp = nums;  

  //Check individual digit of each number

 while(nums > 0)

 {

  //Get remainder

  remain = nums%10;  

  nums/=10;

  value+=Math.pow(remain,3);//Find cube of number

 }

 if(temp == value) //Check if number is armstrong

 {

  new_Arms = value;

  old_Arms = new_Arms - old_Arms;

  System.out.println(value+"\t\t\t"+old_Arms);//Print Valid Armstrong Number

  old_Arms = value;      

 }

 count++;  

 }

 

 return true;  

};

}

See Attachment for Program file

Ver imagen MrRoyal