
Plz Help!!!!
To anybody,
I am making a doing the problem of the week in math, and i am making a
program in java to do it. I have the program almost done, and it compiles,
but then when i run it, the program goes, and then just stops halfway into
he program. No matter what i do to the program, it keeps on doing it. i
have been doing java for a couple weeks now, so i am still pretty week at
the languagte. plz Help!!
Here is the math problem, and the programs code.
problem of the week goes like this. Blah, Blah, Blah, find all the numbers
between 1000 and 9999 that the first two numbers and the last two numbers
equal each other. like 1001, or 9018 or 3571, like that. Plz Help!
class Math4
{
int finalnum;
int a;
int b;
int c;
int d;
int z;
int ab;
int cd;
public static void main(String arguments[])
{
Math4 mh = new Math4();
mh.numbers();
mh.program();
mh.exit();
}
void numbers()
{
a=1;
b=0;
c=0;
d=0;
z=0;
}
void program()
{
ab = a + b;
cd = c + d;
while (ab != cd)
{
d = d + 1;
if (d == 10)
{d = 0;c = c + 1;}
if (c == 10)
{c = 0;b = b + 1;}
if (b == 10)
{b = 0;a = a + 1;}
ab = a + b;
cd = c + d;
}
z = z + 1;
System.out.println(" "+a+""+b+""+c+""+d+" ");
d = d + 1;
}
void exit()
{
System.out.println("The Number of Combinations is "+z);
program();
}
}