Computer Science Canada

Trying to make a program to read a phrase and determine if it has use in anyway

Author:  deworld [ Tue Nov 24, 2015 10:08 pm ]
Post subject:  Trying to make a program to read a phrase and determine if it has use in anyway

What is it you are trying to achieve?
To make a program that reads a phrase/string and determine if it has use in it or not(ex. Dadsa adsiu s de ) that would count as a use


What is the problem you are having?
when i try to write a program to make it output the problem it fails to do so


Describe what you have tried to solve this problem
I've tried to use a for loop to check


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


var phrase : string
var useword : string := "use"
var numword : int
put "Please enter a phrase to check if it contains use in it"
get phrase : *

for x : 1 .. length (phrase)
    if Str.Lower(phrase)= useword then
    put "use has been found"
    numword := x
    put "The word 'use' has been found in the ", numword ," character"
    end if
end for




Please specify what version of Turing you are using
4.1

Author:  deworld [ Tue Nov 24, 2015 10:14 pm ]
Post subject:  RE:Trying to make a program to read a phrase and determine if it has use in anyway

have no idea how to read the phrase and pluck out u s and e from it

Author:  TokenHerbz [ Wed Nov 25, 2015 6:08 pm ]
Post subject:  RE:Trying to make a program to read a phrase and determine if it has use in anyway

you might want to take a gander at this here article about string manilupation

http://wiki.compsci.ca/index.php?title=Turing_String_Manipulation

basically what you could do is go through the phrase and check to see if the useword exists in it, one letter at a time, (keep in mind of spaces).

Heres a little starter point so you can play around with it. good luck buddy!!

code:

var useword : string := "u s e"

for i: 1 .. length(useword)
    put ord(useword(i))
end for


: