``````1.
/*
2.
* Program: Chapter 3 Lab 1 - Programming Project 8 on page 164
3.
*
4.
* This program caculates the solution to the cryptarithmetic
5.
* puzzle TOO + TOO + TOO + TOO = GOOD where each letter represents
6.
* a single digit with no duplication. It loops all possible
7.
* values for each digit, ensures that the digit are unique, computes
8.
* the sum, and if the equation is satisfied outputs the value
9.
* each digit
10.
* We must make sure to account for the possiblilty of carries when
11.
12.
*
13.
* Student Name: Kenya Hyatt
14.
*
15.
* Date: September 18, 2010
16.
*/
17.
public class Ch3Lab1
18.
{
19.
public static void main(String[]args);
20.
{
21.
int t,o,d;
22.
// Loop over all values for "T","O","G" and "D"
23.
for(t= 0; t<=9; t++)
24.
for(o= 0; o<=9; o++)
25.
for(g= 0; g<=9; g++)
26.
for(d= 0; d<=9; d++)
27.
{
28.
//Ensure uniquences foe each digit
29.
if ((t !=o) && (t !=g) && (t !=d) && (o !=g) && (o !=d) && (g !=d))
30.
{
31.
// Compute rightmost carry and digit
32.
int carry0 = (o + o + o + o) /10;
33.
int digit0 = (o + o + o + o) %10;
34.

35.
// Compute second digit from right
36.
int carry0 = (carry0 + o + o + o + o) /10;
37.
int digit0 = (carry0 + o + o + o + o) %10;
38.

39.
// compute third digit from right
40.
int carry2 = (carry1 + t + t + t + t)/10;
41.
int digit2 = (carry1 + t + t + t + t)%10;
42.

43.
//Check if equation matches7
44.
if((carry2==g) && (digit2==o) && (digit1==o) && (digit0==d))
45.

46.
System.out.println("The values are: T ="+ t + "O=" + o +"G=" + g +"D="+ d);
47.

48.

49.
}// closes second if statement
50.
}// closes first if statement
51.
}// closes first for loop
52.

53.

54.

55.
}// closes main method
56.
}//closes class``````
brandonrunyon commented: Seriously? +0

you think re-posting the question will help?

While silence is sometimes said to say a lot, in your case silence leaves one wondering, what is the question?

Mike

guess his code is not doing what the description says, and he's wondering why

man... there are some strange curly brace placements in that code... I see that the for loops are iterating some ints, but I don't know what statement is being looped for each of them, there are no statements in them. I'm assuming the third curly brace is your body statement, and while java isn't my principle language, I don't know that the first two for's are going to do anything since they have no bodies... I could be wrong. I don't see any indentation, which is not an upset to the compiler, but hard for a regular sentient human to read well. I would try to run your code, but then I'd have to cut out all your numbers from the lines you clearly forgot to copy and paste as unformatted txt.

After extensive 'checking' I award your code and post a -2 for clarity and a +1 for application of cryptography to a clear text post, making it impossible for any mere mortal to decipher.

Here is a nice Java tutorial :)