anyone tell question number 7
Answers
I am using the Scanner Class. But you may use InputStreamReader or BufferedReader also...
****************************************************************************************************
import java.util.*;
public class armstrong {
public static boolean check ( int n ) {
int s = 0, t = n;
while ( t > 0 ) {
s += ( int ) ( Math.pow( ( t % 10 ), 3 );
t \= 10;
}
if ( s == n ) return true;
else return false;
}
public static void main ( String args [] ) {
System.out.println ( " Enter the values of M and N. " );
Scanner in = new Scanner ( System.in );
int M = in.nextInt( ), N = in.nextInt( );
for ( ; M < = N ; M++ )
if ( check ( M ) ) System.out.print ( M ); //calling the function and checking
//the number is armstrong or not
} }