# 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 06: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"?

##### Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

"

"

## X vBulletin 4.2.2 Debug Information

• Page Generation 0.11844 seconds
• Memory Usage 2,839KB
• Queries Executed 13 (?)
Template Usage (32):
• (1)footer
• (1)forumjump
• (1)forumrules
• (1)gobutton
• (3)memberaction_dropdown
• (1)navbar
• (1)navbar_moderation
• (1)navbar_noticebit
• (1)navbar_tabs
• (2)option
• (3)postbit
• (3)postbit_onlinestatus
• (3)postbit_wrapper
• (1)spacer_close
• (1)spacer_open
• (1)tagbit_wrapper

Phrase Groups Available (6):
• global
• inlinemod
• postbit
• posting
• reputationlevel
Included Files (26):
• ./global.php
• ./includes/class_bootstrap.php
• ./includes/init.php
• ./includes/class_core.php
• ./includes/config.php
• ./includes/functions.php
• ./includes/class_friendly_url.php
• ./includes/class_hook.php
• ./includes/class_bootstrap_framework.php
• ./vb/vb.php
• ./vb/phrase.php
• ./includes/functions_calendar.php
• ./includes/functions_bigthree.php
• ./includes/class_postbit.php
• ./includes/class_bbcode.php
• ./includes/functions_reputation.php
• ./includes/functions_notice.php
• ./packages/vbattach/attach.php
• ./vb/types.php
• ./vb/cache.php
• ./vb/cache/db.php
• ./vb/cache/observer/db.php
• ./vb/cache/observer.php

Hooks Called (70):
• init_startup
• friendlyurl_resolve_class
• init_startup_session_setup_start
• database_pre_fetch_array
• database_post_fetch_array
• init_startup_session_setup_complete
• global_bootstrap_init_start
• global_bootstrap_init_complete
• cache_permissions
• fetch_foruminfo
• global_state_check
• global_bootstrap_complete
• global_start
• style_fetch
• global_setup_complete
• strip_bbcode
• friendlyurl_clean_fragment
• friendlyurl_geturl
• forumjump
• cache_templates
• cache_templates_process
• template_register_var
• template_render_output
• fetch_template_start
• fetch_template_complete
• parse_templates
• notices_check_start
• notices_noticebit
• process_templates_complete
• friendlyurl_redirect_canonical
• bbcode_fetch_tags
• bbcode_create
• postbit_factory
• postbit_display_start
• postbit_imicons
• bbcode_parse_start
• bbcode_parse_complete_precache
• bbcode_parse_complete
• postbit_display_complete
• memberaction_dropdown
• tag_fetchbit_complete
• forumrules
• navbits
• navbits_complete