Author |
Message |
Mike
|
Posted: Wed Nov 06, 2002 6:49 pm Post subject: Check this out |
|
|
help with turing programs
1.Write a program that reads words entered one to a line and counts how many words have been entered before you give the signal word"end"to stop execution of the program. Experiment to determine what happens if you put several words on a line as you enter them.
2.Write a program that announces at each repetition of loop the number of times it has executed the loop. Have it stop at each execution with a message
Type "more" to continue |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Mike Pastah
|
Posted: Fri Nov 08, 2002 5:22 am Post subject: (No subject) |
|
|
I don't get the first question, but I think this might help for the second:
code: | var a, c : string
var n, b : int
n := 0
loop
n += 1
put "Enter your name: " ..
get a
put "Hello, ", a, ", how old are you? " ..
get b
put b, " eh? Cool."
delay (1000)
put "You've done this loop ", n, " times"
delay (1000)
loop
put "Type 'more' to continue this program."
get c
if c = "more" then
put " "
else
put " "
end if
exit when c = "more"
end loop
end loop
|
|
|
|
|
|
|
Crimson_Hunter
|
Posted: Fri Nov 22, 2002 6:52 pm Post subject: (No subject) |
|
|
You are making it way too complicated. It goes like this:
code: |
var wait : string
var count : int
loop
count += 1
put count
get wait
if wait not= "more" then
exit
end if
end loop
| [/code] |
|
|
|
|
|
moju
|
Posted: Tue Nov 26, 2002 4:33 am Post subject: REALLY EASY |
|
|
I HAD THE SAME ASSIGNMENTS AS YOU!!!
[/code]
var word:string
var count:int
word:=""
count:=0
put "Word Counter"
put "------------"
put " "
colour(12) %user prompt
put "Enter words, then end with end"
% loop to allow user to enter words
loop
get word
% exit loop if word is "xxx"
exit when word = "end"
%increment counter
count := count +1
end loop
put "count is ",count |
|
|
|
|
|
moju
|
Posted: Tue Nov 26, 2002 4:38 am Post subject: (No subject) |
|
|
[/b][/code] var num :real
var more : string
num :=1
loop
put "Loop execution number, ", num
put "Enter 'more' to continue"
num := num +1
get more
exit when more not= "more"
end loop
put "It execution stopped because you didn't type in 'more'" |
|
|
|
|
|
moju
|
Posted: Tue Nov 26, 2002 4:41 am Post subject: (No subject) |
|
|
code: | var num :real
var more : string
num :=1
loop
put "Loop execution number, ", num
put "Enter 'more' to continue"
num := num +1
get more
exit when more not= "more"
end loop
put "It execution stopped because you didn't type in 'more'"
|
|
|
|
|
|
|
Thanos
|
Posted: Thu Nov 28, 2002 3:38 am Post subject: (No subject) |
|
|
LOL, are these assignments from the Turing textbook called "An Introduction to Programming in Turing" by J.N.P. Hume?hehe |
|
|
|
|
|
|