Computer Science, asked by arnav9688, 2 months ago

. A number is called Armstrong number if the sum of cube of each digit of the number is equal to that number.

(e.g. 153 is a Armstrong number because 153 = 1

3 + 53 +33

).

Define a class armStrong that has the following functions.

public int sumOfDigit(int N) -> which returns the sum of cube of each digit present in N.

public static void main(int x, int y) -> which displays all the Armstrong numbers between the range x and y​

Answers

Answered by sriunugoud243
3

Explanation:

class ArmstrongExample{

public static void main(String[] args) {

int c=0,a,temp;

int n=153;//It is the number to check armstrong.

temp=n;

while(n>0)

{

a=n%10;

Answered by guruu99
0

For example, if x=100 and y=200, then it should display the Armstrong numbers between 100 and 200 (both inclusive).

An Armstrong number is a number that is the sum of its own digits each raised to the power of the number of digits.

For example, 153 is an Armstrong number because 1^3 + 5^3 + 3^3 = 153.

The class armStrong should contain a function sum Of Digit which takes in an integer N and returns the sum of cube of each digit present in N. The main function should take two integers x and y as input and display all the Armstrong numbers between the range x and y (both inclusive).

To find the Armstrong numbers between x and y, we first need to find the sum of cube of each digit present in the numbers between x and y. We can do this using a loop which iterates from x to y and for each number, calculate the sum of cube of each digit. If the sum is equal to the number, then it is an Armstrong number. We can use an if statement to check if the sum is equal to the number and if so, print the number. Finally, we can print all the Armstrong numbers between x and y.

To know more about Armstrong number

https://brainly.in/question/1491582

For more questions related to Armstrong number

https://brainly.in/question/12733733

#SPJ3

Similar questions