
-----------------------------------
Genisis
Fri Oct 14, 2005 8:09 am

i dont know why this is coming up as an error
-----------------------------------
will someone help me with this?

Code:

colorback (brightpurple)
cls
var nam : string
var age : int
var wag : real
var tim : real
var pay : int
loop
    put "Hello what is your name?"
    get nam
    delay (1000)
    cls
    put "How old are you?"
    get age
    delay (1000)
    cls
    put "How many hours did you work this week?"
    get tim
    delay (1000)
    cls
    if tim >= 50 then
        put "You work to much"
    end if
    put "How many dollars do you make per hour?"
    get wag
    delay (1000)
    cls
    pay := wag * tim
    put nam, " you will be getting a pay of ", pay, "$ this pay check"
    put "For the ", tim, " hours that you have worked"
    put "This program will restart in 10 seconds"
end loop

-----------------------------------
ZeroPaladn
Fri Oct 14, 2005 8:53 am


-----------------------------------
this is probably for school, eh? dont worry, i helped you out. yor vaiables wag and tim are set as real numbers. just reser the varibale type to integers, and it runs.

here, ill repost the code for ya.
colorback (brightpurple) 
cls 
var nam : string 
var age : int 
var wag : int % this used to be var wag : real
var tim : int % thi used to be var tim : real
var pay : int 
loop 
put "Hello what is your name?" 
get nam 
delay (1000) 
cls 
put "How old are you?" 
get age 
delay (1000) 
cls 
put "How many hours did you work this week?" 
get tim 
delay (1000) 
cls 
if tim >= 50 then 
put "You work to much" 
end if 
put "How many dollars do you make per hour?" 
get wag 
delay (1000) 
cls 
pay := wag * tim 
put nam, " you will be getting a pay of ", pay, "$ this pay check" 
put "For the ", tim, " hours that you have worked" 
put "This program will restart in 10 seconds" 
end loop[\code]



-----------------------------------
jamonathin
Fri Oct 14, 2005 10:41 am


-----------------------------------
The reason why you have to change it from ' : real ' to ' : int ' is because an integer (int) has to be a whole number. 

So, since an int has to be a whole number then this should work, right?


var R : real

R := 10

var I : int

I := R
  But why doesn't this work?

My theory is, that the programmers of Turing were too lazy to check when an integer variable is added by (or made value of) a real number, if the number is whole or not.  
So instead what you have to do is round the number first.

var R : real

R := 10

var I : int

I := round(R)

'round ()' converts a real number into an integer acceptable number.  Doesn't make sense sometimes but neither do a lot of things.

** So,  'round ()' also works for other commands that require integer values.  Such as any of the 'Draw' commands.  You CAN use real numbers in the command, you just have to use 'round (real)' instead of just putting your 'real' variable. **

I hope this made sense :)

-----------------------------------
[Gandalf]
Fri Oct 14, 2005 3:09 pm


-----------------------------------
Oh, and use more meaningful variable names.  This isn't BASIC where you are limited on variable name length, and I think even that allowed more than 3 letters :).

-----------------------------------
Finaltank
Fri Oct 14, 2005 3:29 pm


-----------------------------------
To fix this turn your 'int's to 'real's

Pink is a hellish background

-----------------------------------
jamonathin
Fri Oct 14, 2005 7:56 pm


-----------------------------------
Woah woah, dont diss the pink.  Just because you joined compsci on my birthday doesn't mean you can knock on a pink background.

P.I.N.K. -> Pwnage In New Kolor

-----------------------------------
Genisis
Fri Oct 14, 2005 9:50 pm


-----------------------------------
thanks guys i didnt see that intell i posted this and then my friend help me out to thanks for ur help too
