hi 
for the first problem you could do something like this:
public class Mymath {
public calculateFactor( int a, int b ) {
if ( a < b && b % a == 0 )
return true;
elif ( a > b && a % b == 0 )
return true;
else
return false;
}
}
and for the second part see if this is any helpful
:
import java.util.Scanner;
public class Test {
public static void main( String[] args ) {
Scanner in = new Scanner( System.in );
String goOn = "y";
int n, largest = 0;
do {
System.out.println( "Input an integer number:" );
n = in.nextInt();
for ( int i = 1; i < n; i++ )
if ( n % i == 0 )
if ( i > largest )
largest = i;
System.out.println( "Largest divisor: " + largest );
System.out.println( "Another input (y/n)?" );
goOn = in.nextLine();
goOn = in.nextLine(); //doesn't work in there's only one don't know why.
largest = 0;
} while ( goOn.equals( "y" ) );
}
}
Your first code will not compile and it is not java (elif)
The second is totally inefficient and shows no thinking at all to the real problem
Reputation Points: 1014
Solved Threads: 446
Nearly a Senior Poster
Offline 3,259 posts
since Dec 2007