i am doing a few revision questions before i go back to college next week and i think i have done this wrong ( the code i put together finds the factor of the numbered entered ) here is the question and the code i have done so far.
Write a program that will determine whether a number entered has either 3 or 11 as a factor.
// revision practical 6c question 5
// Gman
// 4.11.11
import java.util.Scanner;
public class NumberFactorEntered
{
public static void main(String[] args)
{
Scanner kb = new Scanner(System.in);
// declare variable
int num1 = 0;
// get number
System.out.print("Enter a number : ");
num1 = kb.nextInt();
// calculate number to find the factors
for ( int i = 1; i <= num1; i++)
{
// if number has no remainder than display
if ( num1 % i == 0 )
{
System.out.println(i + " is a Factor of " + num1);
}
}
}
}


Sign In
Create Account


Back to top









