Today I also asked Mr.Arkin about substrings, hears what I learned : for the first letter of a word to be displayed the variable name must be given in a put statement followed by (1), for the second letter it is the same case scenario, however (2) replace (1). For the last letter of a word to be displayed, the variable name is stated in a put statement and is followed by (*). For the second last letter in a word the variable name is stated in a put statement and is followed by (* - 1). Here is the code for the first two substring assignments :
#1
const DELAY := 1000
var letters : int
var name : string
put "Letters? (no more than 6) : " ..
get letters
put "Word? : " ..
get name : *
case letters of
label 6 :
put name (1)
delay(DELAY)
put name (2)
delay(DELAY)
put name (3)
delay(DELAY)
put name (4)
delay(DELAY)
put name (* -1)
delay(DELAY)
put name (*)
delay(DELAY)
label 5 :
put name (1)
delay(DELAY)
put name (2)
delay(DELAY)
put name (3)
delay(DELAY)
put name (* -1)
delay(DELAY)
put name (*)
delay(DELAY)
label 4 :
put name (1)
delay(DELAY)
put name (2)
delay(DELAY)
put name (* -1)
delay(DELAY)
put name (*)
delay(DELAY)
label 3 :
put name (1)
delay(DELAY)
put name (* -1)
delay(DELAY)
put name (*)
delay(DELAY)
label 2 :
put name (1)
delay(DELAY)
put name (*)
delay(DELAY)
label 1 :
put name (1)
delay(DELAY)
label :
put "Please enter valid letter count!"
end case
put "Done!"
#2
const DELAY := 1000
var letters : int
var name : string
put "Letters for word? (no more than 6) : " ..
get letters
put "Word? : " ..
get name : *
case letters of
label 6 :
put name (*)
delay(DELAY)
put name (*-1)
delay(DELAY)
put name (4)
delay(DELAY)
put name (3)
delay(DELAY)
put name (2)
delay(DELAY)
put name (1)
delay(DELAY)
label 5 :
put name (*)
delay(DELAY)
put name (*-1)
delay(DELAY)
put name (3)
delay(DELAY)
put name (2)
delay(DELAY)
put name (1)
delay(DELAY)
label 4 :
put name (*)
delay(DELAY)
put name (*-1)
delay(DELAY)
put name (2)
delay(DELAY)
put name (1)
delay(DELAY)
label 3 :
put name(*)
delay(DELAY)
put name(*-1)
delay(DELAY)
put name(1)
delay(DELAY)
label 2 :
put name(*)
delay(DELAY)
put name(1)
delay(DELAY)
label 1 :
put name (1)
delay(DELAY)
label :
put "Please enter valid letter count!"
end case
put "Thank you!"
I will try and do as many assignments I am capable of doing, if I cannot do some of them they I shall ask Mr.Arkin for advice.
No comments:
Post a Comment