I have an assignment for my computer organization class and I'm a little stuck. My professor wants us to create a java program that translates a made-up language: Tiny into a java program that runs correctly.

here is the spec for The Tiny Programming Language:

There is only one data type: integer.
A legal identifier may have one and only one lowercase letter in it (thus there are only 26 possible different identifiers).
A literal integer may have one and only one digit in it. Thus, the only literals are 0 to 9; no larger integers and no negative integers.
There are no declaration statements. All possible identifiers are implicitly delared to be integers and are initialized to 0.
All addition is done modulo 1000.
Statements must begin in column one and may contain no blank or tab characters.
There are three (and only three) kinds of statements in Tiny (in this description, the symbol A represents any legal identifier and the symbols X and Y represent any legal identifier or literal):

There are three statements types in Tiny.
A=X
Assigns the value of X to variable A. Remember, A can be any variable and X can be any variable OR single-digit number.

A=X+Y
Assigns the sum of X and Y to variable A. Remember, A can be any identifier. X and Y can be any identifier OR single-digit number. Thus, although the largest constant is 9, variables can take on values larger than 9.
(X)

Outputs the value of X followed by a newline character. Remember, X can be any variable OR single-digit number.

MY program works almost completely, the problem i have run into is that for my input data:

x=5
(3)
(x)
y=x+9
(z)
(y)
a=9+2
(a)

the variable z is never declared, in Tiny there are no declarations everything is declared implicitly and is initialized to 0. So instead of printing 0 my translated program gives me an error because I havent declared z.

Here is my code:

And here is the translated code i get with these inputs:

x=5
(3)
(x)
y=x+9
(z)
(y)
a=9+2
(a)

Any help would be great.
Thanks,
Hunter

"If the facts don't fit the theory, get new facts" --Albert Einstein

Yes that is what I need to do to declare z, but I don't really want to hard code int z = 0; into the program its supposed to be able to translate the program no matter the inputs.

If i hard coded int z = 0; in then switched z to f then I would have to hard code for f as well, I'm looking for a more versatile solution.

Yes you are correct Henry that does cause another problem: I believe I have fixed both my problem and the one you brought up, its a bit clumsy but it works. Let me know what you think.