class Factors{
private int value;
int SolutionFac1, SolutionFac2;
private int FacArray[][];
public int SolutionArray[] = new int[2];
public Factors(int value){
this.value = value;
FacArray = new int[2][value];
}
public int[][] FindFacs(int number){
int slot = 0;
float modulus;
int divisor, result;
for(divisor = 1; divisor <= (number/2); divisor++){
if(number%divisor==0){
result = number/divisor;
if(divisor <= result){
FacArray[0][slot]=divisor;
FacArray[1][slot]=result;
slot++;
};
};
};
return FacArray;
}
public int[] TestA(int a){
FacArray[0][0] = SolutionFac1;
FacArray[1][0] = SolutionFac2;
SolutionArray[0] = SolutionFac1;
SolutionArray[1] = SolutionFac2;
return SolutionArray;
}
public int[] TestC(int c, int b){
for(int retrieval = 0; retrieval < c; retrieval++){
FacArray[0][retrieval] = SolutionFac1;
FacArray[1][retrieval] = SolutionFac2;
if((SolutionFac1 + SolutionFac2) == b) break;
}
SolutionArray[0] = SolutionFac1;
SolutionArray[1] = SolutionFac2;
return SolutionArray;
}
}
public class EqnFac{
public static void main(String args[]){
int a = 6;
int b = 6;
int c = 9;
Factors aFac = new Factors(a);
Factors cFac = new Factors(c);
aFac.FindFacs(a);
cFac.FindFacs(c);
aFac.TestA(a);
cFac.TestC(c,b);
System.out.print("Factored form of equation is: ");
System.out.print( "(" + a + "x + " + cFac.SolutionFac1 + ")" );
System.out.print( "(x + " + cFac.SolutionFac2 + ")" );
}
}
System.out.print( "(" + a + "x + " + cFac.SolutionFac1 + ")" );
System.out.print( "(x + " + cFac.SolutionFac2 + ")" );
Where is SolutionFac1 and 2 method? I dont see any methods in your program. class Factors{
private int value;
private int SolutionFac1, SolutionFac2;
private int FacArray[][];
public int SolutionArray[] = new int[2];
public Factors(int value){
this.value = value;
FacArray = new int[2][value];
}
public int[][] FindFacs(int number){
int slot = 0;
float modulus;
int divisor, result;
for(divisor = 1; divisor <= (number/2); divisor++){
if(number%divisor==0){
result = number/divisor;
if(divisor <= result){
FacArray[0][slot]=divisor;
FacArray[1][slot]=result;
slot++;
};
};
};
return FacArray;
}
public void TestFacs(int c, int b){
for(int retrieval = 0; retrieval < c; retrieval++){
FacArray[0][retrieval] = SolutionFac1;
FacArray[1][retrieval] = SolutionFac2;
if((SolutionFac1 + SolutionFac2) == b) break;
}
}
public int GetSolution1(){
return SolutionFac1;
}
public int GetSolution2(){
return SolutionFac2;
}
}
public class EqnFac2{
public static void main(String args[]){
int a = 6;
int b = 6;
int c = 9;
Factors aFac = new Factors(a);
Factors cFac = new Factors(c);
aFac.FindFacs(a);
cFac.FindFacs(c);
cFac.TestFacs(c,b);
System.out.print("Factored form of equation is: ");
System.out.print( "(" + a + "x + " + cFac.GetSolution1() + ")" );
System.out.print( "(x + " + cFac.GetSolution2() + ")" );
}
} // 1x^2 + 7x + 6
int a = 1;
int b = 7;
int c = 6
// Multiply a * c, which = 6
// So take note of the second sign in the equation which is a '+'
// So what factors of (a * c) add up to 'b'. I know they have to add because
// of the + sign in the second part.
// So the factors of six are (1 * 6), (2 * 3)
// (1 * 6) those numbers add up to 7!
// so (x + 1) (x + 6) are your factors for 1x^2 + 7x + 6
This is the first case I would test for. (a value being 1)