# Thread: How to do a trace table?

1. Registered User
Join Date
Dec 2005
Posts
1

## How to do a trace table?

Well I'm new to Java programming and I have to make a trace table for a certain algorithm. I know it should be pretty simple, but here is the program I'm suppose to make it on.

public void tryValidPin()
{
int pin = 0;
do
{
pin = inputInt("Pin:");
output( validPin(pin) );
} while (!validPin(pin) && pin>0);
}

public boolean validPin(int pin)
{
int sum = 0;
int product = 1;

while (pin>0)
{
int digit = pin % 10;
sum = sum + digit;
if (digit != 0)
{
product = product * digit;
}
pin = pin / 10;
}
if ( (sum % 10) == (product % 10) )
{ return true; }
else
{ return false; }
}

Okay I know for the columns it is the varibles and boolean. So these are the varibles I found:
pin, product, digit, sum, digit !=0, sum, sum%10, product%10, the final boolean

Now my input is 22.. so how is this suppose to work really?

so let's say..
pin= 22
product= 1
digit=1
digit != 0 = 22
sum= 22
sum%10= 2
product%10=22
final boolean= false

and so.. what else now? =[

I also have an encrytion program... but I want to see if I can understand this first. Thanks =]
Last edited by LearningNerd; 12-07-2005 at 05:35 PM. Reason: stupid math makes me think truth table

2. ummm..didnt understand ur quetion..can u elaborate pls

3. Umm... what do you mean by a "trace table"?