can someone fic this program plz
Author |
Message |
new programmar
|
Posted: Tue Apr 13, 2004 5:31 pm Post subject: can someone fic this program plz |
|
|
var guess, hidden, tries : string
var continue: real
randomize
put "Welcome to the wonderfull number guessing Game"
put " "
put "Guess a number between 1 and 200."
put " "
tries = "0"
rand (hidden( 1, 100)
loop
put "Please enter a number between 1 and 200"
read "guess"
tries = "tries + 1"
exit when guess := "hidden"
end loop
put " "
Put "Graet, you got the number is "
put " "
tries, guesses |
|
|
|
|
|
Sponsor Sponsor
|
|
|
gamer
|
Posted: Tue Apr 13, 2004 5:47 pm Post subject: (No subject) |
|
|
i'll point out wuts wrong with ur code.....but i aint gonna change them for u cuz i think thats ur job (just double check n look up in help manual)
code: | rand (hidden (1, 100) | slightly wrong coding
code: | put "Please enter a number between 1 and 200"
read "guess" | so here u ar trying to allow the user to input the number guessed?? if so, u dont use the read command......also u dont put quotations " " around the variable u getting
code: | tries = "tries + 1" | quotation problems
code: | exit when guess := "hidden" | WRONG
code: | Put "Graet, you got the number is " | um...did u take english course?
code: | put " "
tries, guesses | the order is kinda wrong, also u dont even have the variable called guesses |
|
|
|
|
|
AsianSensation
|
Posted: Tue Apr 13, 2004 5:49 pm Post subject: (No subject) |
|
|
I really think you should learn some basic syntax first. Most of these are just syntax errors. I don't know if it's because you don't understand it, or you don't know how to use the different commands.
code: | var guess, hidden, tries : int
var continue : real
randomize
put "Welcome to the wonderfull number guessing Game"
put " "
put "Guess a number between 1 and 200."
put " "
tries := 0
randint (hidden, 1, 100)
loop
put "Please enter a number between 1 and 200"
get guess
tries := tries + 1
exit when guess = hidden
end loop
put " "
put "Graet, you got the number is "
put " ", tries, guess |
|
|
|
|
|
|
EDEN-E
|
Posted: Tue Apr 13, 2004 8:22 pm Post subject: Re: can someone fic this program plz |
|
|
code: | var guess, hidden, tries : int
% ": string, int, or real" tell the types of variables.
% int type is for integer numbers. .., -2, -1, 0, 1, 2, ..
% real type : numbers that have decimal place. 0.1, 3.14 ..
% string type : character, words, sentance... "apple", "turing" ...
var continue : real
% you didnot use this variable.
randomize
put "Welcome to the wonderful number guessing Game"
% misspell ~ wonderfull(X)
put " "
put "Guess a number between 1 and 200."
put " "
tries := 0
% When you give a value to variable, use :=, not =.
% you do not use "", when variable is for numbers (int, real types)
% Only when variable is string types, you use "".
% i.e. number := 10
% text := "example"
randint (hidden, 1, 100)
% Wrong syntax
% and this will produce any number between 1 and 100
% but your program says, 1 to 200
loop
put "Please enter a number between 1 and 200"
get guess
% you should use 'get' to allow user to enter something.
% also if you put "" around variable, program does not
% recognize it as a variable.
tries := tries + 1
% same "" problem. tries variable is for number.
exit when guess = hidden
% when you compare two variables, use =, not :=.
end loop
put " "
put "Great, you got the number is ", tries, guess
% i can't understnad...
% i guess... you shoud put tries and guess separately |
|
|
|
|
|
|
|
|