I'll start off by saying I'm not exactly certain what you want your code to do because I don't know java.
Something I can say though is that the internal define expressions are definitely tripping you up. In racket you generally cannot define a global variable within an expression, but would rather create a local binding with a form like:
(let ([identifier expression]
...
[id-n expression-n])
body-expressions)
by which the body expressions are evaluated with the specified bindings, the last of which is returned as the result of the entire let expression. This is one way to do multiple things and return one result. Within the context of an (if test consequent alternative)
statement you could group multiple expressions together (eg as a consequent) using the (begin expression...)
form, which executes all expressions and returns the result of the last expression. An alternative would be to use a cond expression, which has the form:
(cond [test conequents]
...
[test-n cons-n]
[else expression])
Each such test can have multiple consequents, so this might be clearer than using several begins.
Also, if you really want to mutate the value of num and x you would use the (set! id value)
procedure, but this is unidiomatic for racket as a functionally recursive form would be preferred.
Going beyond these points requires some guesswork on my part but it looks like you are working within a function that takes two arguments, x and num, and want to increment num until it reaches the value of x, printing the values of x and num along the way, and if given an x value larger than num, you want to return an error
In racket you could do this recursively like so:
(define inc-print ;defining inc-print
(lambda (x num) ;a function of two arguments
(cond [(> num x) "error"]
[(< num x)
;the printf command takes a string and prints it.
;you can add values to the string by inserting ~a's followed by as many
;expressions as ~a's
;\n is shorthand for (newline) so that subsequent calls to printf print on a newline
(printf "The value of x is ~a and num is now ~a\n" x num)
;a recursive call to inc-print with num incremented by 1 and x the same
(inc-print x (+ num 1))]
[else num])))
example:
> (inc-print 5 2)
The value of x is 5 and num is now 2
The value of x is 5 and num is now 3
The value of x is 5 and num is now 4
5
Let me know if this answered your question!