Turing/Help

From Wikibooks, open books for an open world
< Turing
Jump to: navigation, search

Welcome to the Turing help desk. Have a question? Feel free to ask it here, and somebody will try to answer your question promptly.

Another way to get questions answered, likely more quickly, is to visit the highly active Turing help forums at compsci.ca, where members are quite happy to help you with your code.


In what situations does Turing really work great ?[edit]

i0 := --DavidCary 00:20, 4 October 2005 (UTC)

  • Hi David. Sorry for the late response. #sorrynotsorry Turing is used primarily as a learning tool, and was designed as such. Since it was made for ease-of-use rather than speed or versatility, the only reason you might use Turing is for a simple program, or if you're just getting started with programming.
  • Mostly highschool students
  • To my knowledge, no.
  • Yes, turing runs on windows. It also runs on linux and mac.
  • If you can get linux on it ;)
  • Not that I know of, but I'm not sure.
  • You'll have to buy a copy from holtsoft. If you are a student, and your school/board has purchased a license, you can get a copy for free.
  • Under windows, installation is very simple. I don't use it that often and I haven't used it in a while, so I'm not sure if there are any important notes for installing it on other systems.
Hope that helped! -Frazzydee| 03:29, 5 January 2006 (UTC)

passing parameters[edit]

why is not passing parameters bad programming style? If it works without passing parameters, why not use global variables?

The reasons may vary depending on the program. One of the most common reasons is that your procedures/functions may ultimately be included in a library, where people using your programs will want to just pass the parameters straight to it rather than figuring out all the variable needed. -Frazzydee| 04:23, 24 May 2005 (UTC)

increasing and decreasing a counter by an increasing and decreasing amount??[edit]

So i need to increase a value by zero, then one, then -1, 2, -2, 3, -3... and i have no idea on how to do it. i've been trying to use some variation on

  loop
    counter:=counter+1
    a:=a+(-1)**counter
  end loop

but its just doing a+0 ,a-1, a+1, a-1, a+1 insdead of a+0, a-1,a+1,a-2,a+2 HELP!

I'm not sure I completely understand your question...wouldn't that end up just equalling 0 if you're subtracting and then adding by the same number? -Frazzydee| 11:58, 24 May 2005 (UTC)

It's going a+0 ,a-1, a+1, a-1, a+1 because -1**1=-1, -1**2=+1, -1**3=-1, -1**4=+1...etc. Try:

var y : int
var z : int
for x:1..10
    y:=x
    z:=x
    put "a+", y 
    put "a-", z
end for

Slowing Down Your Program[edit]

How can I slow down the rate at which my program outputs(put) information to the screen? Please help! Urgent!

Answer:

Use delay(n), where n is the number of milliseconds you want the program to pause for. Example:
delay(1000)

will make the program pause for 1 second before executing the next line. -Frazzydee| 22:53, 6 Jun 2005 (UTC)

how do you skip lines[edit]

is there any way you could skip a line under a certain condition

Example

if x=2 "now i need the computer to avoid the data from line 32 to 45"

In most cases, you can just store it to a temporary variable in those lines:
var tmp : string
if x=2 then
     for i : 1 .. 14
          get : inp, tmp
     end for
end if
However, I've had cases where you can't store it to a variable at all, and I'm not sure how to get around that. If you find out how, please post it here! :) -Frazzydee| 02:48, 9 Jun 2005 (UTC)

GOLF SIMULATION ASSIGNMENT[edit]

I am in grade 10, and we were just asked to make a simulation program. With variables such as wind, gravity, etc. Anyways, I've been sick for the past week or so and haven't got anything done because I dont have turing at my home. Can anyone send me a program which will simulate a golf shot? It has to have variables such as wind gravity slice and hook of the shot, and the user can enter thigns such as if he /she is a amteur or pro golfer, therefore affecting how close their shot will be to the hole. Can anyone PLEASE send me a prgram that will do this. I am in HUGE need. THANKS! my email is jamias_666@hotmail.com if u want to send me one. thank you!

 I advice you not to publish email addresses if you don't want to get spam.

Hi i was wondering if you could tell me why this code does not work in turing. it crashes[edit]

procedure info (var base, height, L1, L2, L3 : int)

   put "Please enter the base of the triangle"
   get base
   put "Please enter the height of the triangle"
   get height
   put "Please enter the 1st length of the triangle"
   get L1
   put "Please enter the 2nd length of the triange"
   get L2
   put "Please enter the 3rd length of the triangle"
   get L3

end info

procedure area (var b, h, Area_Triangle : int)

   Area_Triangle:=b*h div 2

end area

procedure pmeter (var L1, L2, L3, Perimeter_Triangle : int)

   Perimeter_Triangle := L1 + L2 + L3

end pmeter

procedure areapmeter (var finalarea, finalperimeter, Area_Triangle, Perimeter_Triangle : int)

   put "The Area of the triangle is", finalarea, "The Perimeter of the triangle is,", finalperimeter
   finalarea := Area_Triangle
   finalperimeter := Perimeter_Triangle

end areapmeter

You have redundant variables like b and base and you defined finalarea and final perimeter after the put. Get rid of the redundant variables and you should be fine:
   %Declare the variables
   var base, height, L1, L2, L3, Area_Triangle, Perimeter_Triangle : int
   
   %Enter in values
   put "Please enter the base of the triangle"
   get base
   put "Please enter the height of the triangle"
   get height
   put "Please enter the 1st length of the triangle"
   get L1
   put "Please enter the 2nd length of the triange"
   get L2
   put "Please enter the 3rd length of the triangle"
   get L3
   %Display
   Area_Triangle := base * height div 2
   
   Perimeter_Triangle := L1 + L2 + L3
   
   put "The Area of the triangle is ", Area_Triangle
   put "The Perimeter of the triangle is ", Perimeter_Triangle

Centering Text[edit]

Could anybody tell me the different ways I can center text in Turing?

Look up locate in the help file. You will need to know the length of the string to center it properly. -Frazzydee| 03:32, 5 January 2006 (UTC)

Exercises[edit]

How do i write a program that allows the user to input any base 10 number then outputs the number into binary?

var tmp : int
var tmpc : string := ""

get tmp

loop
    tmpc += intstr(tmp mod 2)
    tmp := tmp div 2
    exit when tmp=0
end loop

put tmpc

for decreasing i : length(tmpc) .. 1
    put tmpc(i)..
end for
This just keeps on dividing by 2 and recording the remainder, then it reads it backwards. Hope that helped, and sorry for the late response. -Frazzydee| 03:48, 5 January 2006 (UTC)

strings[edit]

outputs a word and determines if the centre word is an uppercase or lowercase?

why won't it out put my inputed word!! after it's been altered[edit]

if choice = 3 then
    loop
        put "title"       %---use quotations---% 
        put "line"

        %setting outputs
        locate (3, 1)
        put "Enter a pattern:"
        locate (4, 1)
        put "Enter a pattern to substitute"
        put "it with:"
        locate (6, 1)
        put "Enter a word to change:"

        %getting inputs
        locate (3, 18)
        get pattA : *
        locate (5, 10)
        get pattB : *
        locate (6, 25)
        get word : *

        if index (word, pattA) not= 0 then
            loop
                pos := index (word, pattA)
                exit when pos = 0
                beg_word := word (1 .. pos - 1)
                end_word := word (pos .. *)
                new_word := beg_word + end_word
                word := new_word
            end loop
        end if

        cls
        put title
        put line
        locate (7, 1)
        put word

    end loop
end if

Making A RPG Game In Turing[edit]

Is it possible to make a RPG in turing? I can make a very basic battle system with hp and such. However I want to make it so you can level up and use items and all that. With a weapon making system of some kind.


Turing is an extrmely limited programming tool/language, making an RPG with level ups and wepons would be extremely difficult if not impossible. This is because Turing is used mainly as a learning tool for beginner programmers to show them the basic elements of programming, a better programmming language to use would be Java maybe, or C++, I really do not recommendd the use of Turing to create a complex game such as the one you describe


i have made a simple(it has levels atk ect.)text based rpg but it is hard to make graphics in my game so instead i wnt for a retro look if you like doing these kind of things you should go to this website.

http://compsci.ca/v3/index.php?pf=120&h=1&start=0

connect four[edit]

i need help writing a program for a video connect four game. i just had pneumonia and have missed 2 weeks or so of school. this project is due very soon and i'm not very good at turing. if somebody could please, please, please help me, that would be greatly appreciated. Thank you so much.



Of course you can make an RPG in Turing. Now, it won't be the graphical equal to Final Fantasy X, but you can make something that looks like a game from the Nintendo/Super Nintendo era without much trouble at all.

Mastermind[edit]

I need to create the game mastermind in Turing code for school. I am extremely lost and confused. I would deeply appreciate the code if someone has it or even just some general help. Thanks

how do I write a program that allows the user to click and make an LED light hooked up to a paper car, hooked up to an experimnetor box blink

I know it[edit]

What am I doing wrong, I know it but I can't remember?

case
    label := "a"
        put "no"
    label := "b"
        put "yes"
    label := "c"
        put "no"
    label := "d"
        put "no"
    label := "e"
        put "no"
end case

Answer:

 := sets the value of a variable. You should be using = for comparison (eg. comparing the value of label to "a"). Try that, and come back if it still doesn't work...sorry, but I don't have time to test it myself right now :( -Frazzydee| 22:58, 26 February 2006 (UTC)

A chat program, with a GUI[edit]

I've got 95% of the code complete. I'm stumped at the actual transfer of information though! I can open a connection, and connect, but I have no way of passing information between the server and the client! Can someone help?

You should be able to use get and put, IIRC. Is there any reason why "get : ns, stringvar" won't work? (where ns is your netstream and stringvar is a string variable). If you're still having trouble, post your code somewhere and I'll take a look at it. -Frazzydee| 23:00, 26 February 2006 (UTC)

umm yee i jus wanted to know like i understand the how the loops work but i dont understand how you get the program to loop so that it starts over again if the user prompts it to like for example.. in the case such as you hav the program run then you get to the end and you loop it so it says exit program if word = no( the user says no i dont want to play again) but how do you get it to start over if the user says yes they do want to start over again ??

Linking[edit]

I'm working on a turing project for school (grade 10 FTW), and I have to create a welcome screen to use in all of my programs. The problem is, I made a really nice one (atleast nice for what we've learned so far) but the code it really long. I don't want to have to copy that into the top of my program everytime. Is there a line of code that I can put into the top of each program to tell it to run the welcome screen first, then continue on to the rest of the program?

You can use include.

For example, if your welcome screen is in a file called welcome.t, you would write

include "welcome.t"

at the beginning of each of your assignments.

Make sure welcome.t is in the same directory as your assignment, though.

Too many Variables.[edit]

I am trying to make a Sudoku game, which has turned out to be a long script. Is there a way I could group variables together to make thing simpler. eg loop if a1 = {anyone of the Variable groups} then a1 := a1+1

== Hi, I was wondering if anyone could tutor me for turing 4.1.1

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Hello, while I won't tudor you, you may find it helpful to look up arrays in the turing reference.


var sampleArray1: array 1..9,1..9 of int  %Creates an array

var sampleArray2: array 1..3,1..6 of int:  %Creates an array and assigns puts values into the array

   =init(1,1,1,1,1,1,
   1,1,1,1,1,1,
   2,2,2,5,6,2)

sampleArray1(1,3):=6  %Assigns the integer 6 to index 1,3 of the array


I hope this helps :)

HELP![edit]

Hey, can anyone tell me what the problem is with this code? It's a program for a rock paper scissors game.

var p1 : char
var p2 : char
var exit_char : string (1)
var p : char
var P : char

put "Note: The 'ROCK-PAPER-SCISSORS' game is meant for two (2) players. \nPress any key to continue. \n\n"
    getch (exit_char)

put "Player 1, enter 'p' for paper, 'r' for rock, or 's' for scissors: "..
get p1
put "Player 2, enter 'p' for paper, 'r' for rock, or 's' for scissors: "..
get p2

if ((p1 = "p" or "P") and (p2 = "p" or "P")) then
    put "\nTie game, nobody wins."
elsif ((p1 = "s" or "S") and (p2 = "s" or "S")) then
    put "\nTie game, nobody wins."
elsif ((p1 = "r" or "R") and (p2 = "r" or "R")) then
    put "\nTie game, nobody wins."

elsif ((p1 = "p" or "P") and (p2 = "r" or "R")) then
     put "\nPlayer 1 wins, paper covers rock."
elsif ((p1 = "r" or "R") and (p2 = "s" or "S")) then
    put "\nPlayer 1 wins, rock breaks scissors."
elsif ((p1 = "s" or "S") and (p2 = "p" or "P")) then
    put "\nPlayer 1 wins, scissor cuts paper."

elsif ((p1 = "p" or "P") and (p2 = "s" or "S")) then
     put "\nPlayer 2 wins, scissor cuts paper."
elsif ((p1 = "r" or "R") and (p2 = "p" or "P")) then
    put "\nPlayer 2 wins, paper covers rock."
elsif ((p1 = "s" or "S") and (p2 = "r" or "R")) then
    put "\nPlayer 2 wins, rock breaks scissors."

else 
     put "\nInvalid choice(s). Remember to enter only one letter; 'p', 'r', or 's'."
end if

Answer

You are not using boolean properly. Rewrite (p1 = "p" or "P") to (p1 = "p" or p1 = "P"), so the first line would be:
if ((p1 = "p" or p1 = "P") and (p2 = "p" or p2 = "P")) then
    put "\nTie game, nobody wins."

Turing help[edit]

Can anyone help me, I need to make a scene where a cowboy jumps off a cliff onto his horse, and rides away. I can make the scene, but I cant seem to get the cowboy to jump down to the horse, and ride away. They are stick figures by the way, on a brown box.

Process and Procedures[edit]

I have a bunch of procedures and at the beginning of each i wanna put a music with a fork. i got it to work but it won't work inside the procedure because u cant' have a process in a procedure. what do i do? please help me!!

problem with strings[edit]

The following code is for a simulated game of mastermind. This is the basic code. Unfortunately, I am having trouble with some of the strings and i've high lighted it... it says *****PROBLEM AREA****

var guess1, guess2, guess3, guess4 :string                          %guesses
var ans1 :int :=Rand.Int (97,101)                                   %generation of answer
var ans2 :int :=Rand.Int (97,101) 
var ans3 :int :=Rand.Int (97,101) 
var ans4 :int :=Rand.Int (97,101) 
var nouveau_guess :int
const ANS :string := chr (ans1)+chr (ans2)+chr (ans3)+chr (ans4)    %answer

put ANS

%instructions
put "Pick four of the following five letters: a, b, c or d \n"

loop
%prompts
put "Enter your first guess: "..
get guess1      

put "Enter your second guess: "..
get guess2

put "Enter your third guess: "..
get guess3

put "Enter your forth guess: "..
get guess4

var GUESS :string := guess1+guess2+guess3+guess4                  %guess

%answer completely correct
if ANS=GUESS then
    put "YOU WIN!"
    exit
end if

%evaluation of guess (completely correct)
for i :1..4
    if GUESS (i)=ANS (i) then
        *****PROBLEM AREA***** i must convert the guess (i) into another character so that it doesn't check it again in the following code    
        put "Correct"
    end if
end for

%evaluation of guess (sort of correct)
for i :1..4
    if GUESS (1) = ANS (i) then
        put "semi-correct"
    end if
    
    if GUESS (2) = ANS (i) then
        put "semi-correct"
    end if
    
    if GUESS (3) =ANS (i) then 
        put "semi-correct"
    end if
    
    if GUESS (4)= ANS (i) then
        put "semi-correct"
    end if
end for
end loop

Answer:

Not sure what is what your are trying to do in the problematic section. Mi guess is that you would need to change the problem area into the following:
var allRight : boolean := true
for i :1..4
    if GUESS(i) not= ANS(i) then
       allRight := false
    end if
end for
if allRight the
    put "Correct"
    exit
end if

Polygon[edit]

I' am doing this assignment and i need to move a polygon but i don't no how soo can u please tell me how. thanks soooo much


It probably has somehting to do with getch and the follow mouse procedure try lookin those up and once you know how to use getch you will probably figure it out

parallel port[edit]

How do use the parallelget function. according to my understanding its more complicated than parallelget(64) . please answer in full detail as i am in g.12. what isBold text MOD and DIV. thanks . ALOT. parallelget is a function with no parameters:

procedure PGet(var val, i0, i1, i2, i3, i4: int)
val := parallelget
i0 := (val div 64) mod 2
i1 := (val div 128) mod 2
i2 := (val div 32) mod 2 
i3 := (val div 16) mod 2
i4 := (val div 8) mod 2 
end PGet


parallelget represents an already determined number, it requires no variables and that is wht parallelget(64) doesnt do anything. use it like a variable, ex. "put parallelget"

programming alphabetically[edit]

yeah, i need to make a program where i ask the user for two words, and then i put it in alphabetical order i have managed to do this by just making my variables word1, and word2, then i just put :

if word1 > word2 then
   put word2,"":2,word1
else
   put word1,"":2, word2
end if

in my program i did include the get statements and the variables... but i just put in the general idea i had for putting things alphabetically. The problem is, both words have to be either upper case, or lower case, i cant word1 as upper, and word2 as lower because lower case words are larger than upper even if the upper starts with "Z" and the lower starts with "a", my program will still display after the words are inputted, Z is before a. how do i make it so it says a before Z?

Base converter (base 2, 8, 10, 16 conversions)[edit]

hi!

i was wondering if i could get some help in converting numbers

i need to convert decimal, hexadecimal, binary and octal into eachother

i know that

binary_out := intstr (decimal_in, 0, 2)

will change decimal_in to binary_out

and

for decreasing n : length (binin) .. 1
        if binin (n) = '1' then
            decout := decout + 2 ** (length (binin) - n)
        end if
    end for

will change the number back to decimal

i am having difficulty with : binary to octal/hex, octal to decimal/binary/hex, and hex to decimal/binary/octal

please help me! thanks ==> why not just convert binary string back to integer (base 10) first? Then you can use "intStr(int, 0, <base>) to convert to Hex or Octal string?

decNumberOut := strint(binStringIn, 2)
octalString  := intstr(decNumberOut, 0, 8)
hexString    := intstr(decNumberOut, 0, 16)

computer science[edit]

what is AB1 in computer science?

calculating tax for output[edit]

can anyone tell me how to make my program calculate tax? I already tried to multiply it by a number on the line itself, but my instructor does not allow it, saying it needs to be done as a variable, where after the price is inputed, you click and it calculates the tax.

Here is the program so far


var Name:string var Price:int var Total:int

put "What is the item you want to buy?" get Name:* put "How much does it cost?" get Price put "With tax, the total bill is.."


well it depends how much the tax is in your area, since i don't what it is in your area, I will prompt the user to input it just like they input the price. Below is the new program:

var Name:string
var Price:int
var Total:int
var Tax : int

put "What is the item you want to buy?"
get Name:* 
put "How much does it cost?"
get Price
put "How much is the tax."
get Tax 
put "With tax, the total bill is.."
Total := (Price * Tax) + Price
put Total

Thats it!, hope it helped


I would suggest using this instead:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   basic menu program                             %
%   written by Drake McIntosh                      %
%   Created: November 26, 2010, 11:37:32 AM        %
%   Last Modified: November 26, 2010, 2:51:23 PM   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
var total : real := 0
var item : int
var more : string
const SALESTAX : real := 0.13
var tax : real := 0
var withtax : real := 0

loop %allows the user to order more than one item.
    put "Menu"
    put "1.Hockey Stick....$65.00"
    put "2.Hockey Gloves...$20.00"
    put "3.Hockey net......$50.00"
    put "4.Hockey Helmet...$60.00"
    put "5.Hockey Tape.....$3.50 "

    put "Which item Would You Like To Order? " ..
    get item
    if item = 1 then %add to total according to menu item selected
        total := total + 65.00
    elsif item = 2 then
        total := total + 20.00
    elsif item = 3 then
        total := total + 50.00
    elsif item = 4 then
        total := total + 60.00
    elsif item = 5 then
        total := total + 3.50
    else
        put "That Is Not A Valid Menu Item"
    end if

    put "Do You Want To Order Anymore? (y/n) "
    get more
    exit when more = "n"
end loop %allows the user to order more than one item.
tax := total * SALESTAX
withtax := total + tax
put "total: ", total
put "tax  : ", tax

put "Your Order Total is: ", withtax

how to do square root[edit]

how do u do the square root in turing

-- i dont know that much about the Turing syntax, but maybe try raising it to the power of 1/2

like: n1/2

~John

Sorry for the late response. You have two methods. Type 1) sqrt(n) or 2) n ^^ 1/2. You should try Computer Science Canada next time. --Mayfare (talk) 23:06, 4 January 2008 (UTC)

Write to file?[edit]

How exactly would you save info to a .txt from turing? This book should help

HELP!!!![edit]

Please help! What are variable and value parameters? please include an example.

Thanks, utterly confused



I am a grade 10 student who attends a "Computer Engineering" class. We have been doing Turing for a while now and we have been assigned a final project worth 30 percent of our marks. The assignment I was given is this:

You have been hired by the grade 10 Computer Science teacher to help students learn new computer terms by creating a Hangman game with the appropriate graphics. As a student enters a letter they think is in the word either a green LED light will light indicating the letter is correct or a red LED will light indicating the letter is wrong.

Peripheral: You must design and build a peripheral which will display 2 LEDs associated with attractively made designs for being correct (green) or wrong (red)

Interface: You must properly assemble a parallel port connector with 2 LEDs and insert them into the peripheral.

Now, I have created my hangman game on Turing with all of the game requirements, except for the peripheral and interface. Our teacher has not covered any of that information; therefore I don’t know how to do it.

Please, if you can explain to me or give me steps to what I should do (even a link to where I can get answers) will be very useful and very well appreciated. Thank you!

hello i am in grade 10. I tried my best to do this but i cant we are doing some practice on chapter 6 of turing and we have to creat a quiz where it ask's for like multiple choice questions,true and false and matching.This quiz consist of 10 questions. After each question the computer must chech if the answer is correct or incorrect, and output the result as well as the number of marks earned for that question. At the end of the test, the computer must print out the final mark for the test in 3 ways: example: 1.A fraction 2.A percentage 3. A letter grade If the test was a 50 percent or lower, the computer must ask if the student would like to re-write the test. If she/he wants to, the computer must loop back to the 1st question and begin again with a blank mark. The student can rewrite a total of 2 times Here are the 10 questions i want to put in order to make the turing program work Multiple choice question

1:What is another name for CPU Here are the options of the answer 1:Microprocessor put " Yes your right" 2:decode put "No try again" 3:execute put"No you're wrong" 4:Microchip put "Nope this is wrong sorry" So these questions i want to put into turing form


One question for true and false 1:Turing is a great programming language if the statement is true then put its right if the statement is false but its wrong

and other questions like this Please i really need help so please tell me ASAP

'how do we do fill in the blank on turing like i want to draw a small line for blank and then put the statement. like _________ is my name so how do i draw the line please helppp ASAPPPPP...'



i need help withh this question for turing 4.1.1 Federal income tax is to be levied in stages on taxable income.On the first $27,500 you pay 17%, on the next $27,500 you pay 24%, an on the rest 29%. Write a program to read in a taxable income and compute the federal tax payable to the nearest cent. (use the current tax for the province of Ontario.)

I have a really annoying problem in my coding to create a hangman game in Turing. The problem is at the bloded and italicised part. Turing says one of the variables has no value, and I have no idea why I need help ASAP, becasue this school project is due Tuesday

 problemous part=------->       '''if guess = trash (d) then'''

% check to not guess letter again, play again, % quit button, win(all right), c'est tout, je pense

setscreen ("graphics:750;550")

var font1, font2, font3, file1, font4, font5, font6, button, wrong, continue : int
var guess : string (1)
var word, playagain, start : string
var a, c, j, k, right, d : int

font1 := Font.New ("Herman:20")
font2 := Font.New ("Sprint:40")
font3 := Font.New ("Sprint:20")
font4 := Font.New ("CLOWNINGWAY:25")
font5 := Font.New ("Papyrus:20")
font6 := Font.New ("Papyrus:55")

wrong := 0    % number of wrong guesses
right := 0    % number of right guesses
continue := 1
d := 0        % NUMBER OF GUESSES MADE
a := Rand.Int (1, 31)

var alpha : array 1 .. 26 of string := init ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
    "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z")
var trash : array 1 .. 26 of string   % trash can


open : file1, "word.txt", get
for i : 1 .. a
    get : file1, word % chooses random word
end for

procedure intro
    colourback (0)
    cls

    Font.Draw ("Are you ready", 145, 400, font6, 7)
    Font.Draw ("to play?", 250, 280, font6, 7)
    Font.Draw ("    Instructions:", 100, 150, font5, 7)

    locate (27, 1)
    put "                   To play the game, just type the letter you want to guess."
    put "                       You DO NOT need to hit enter"
    put "                   You have six chances to guess a wrong letter before you die."
    put "                       Type Y to begin."

    Draw.Box (20, 490, 60, 530, 7)   % top left box
    Draw.Box (690, 20, 730, 60, 7)   % bottom right box

    Draw.Box (40, 40, 710, 510, 7)
    Draw.Line (40, 200, 710, 200, 7)
    Draw.FillBox (300, 190, 450, 210, 0)
    Draw.Box (300, 190, 450, 210, 7)     % rADNOM MIDDLE RECTANGLE

    var picturecake : int := Pic.FileNew ("cake.jpg")
    Pic.Draw (picturecake, 95, 235, picCopy)

    var picturefood : int := Pic.FileNew ("food.bmp")
    Pic.Draw (picturefood, 555, 225, picCopy)

    loop
        locate (30, 42)
        get start
        exit when start = "y" or start = "Y"
    end loop
end intro

procedure game
    colourback (0)
    cls

    loop
        Draw.FillBox (1, 549, 749, 450, 7) % surrounds picture
        var picturedessert : int := Pic.FileNew ("dessert.jpg")
        Pic.Draw (picturedessert, 5, 455, picCopy)

        Font.Draw (" Food Hangman", 138, 485, font2, 7)
        Font.Draw (" Food Hangman", 136, 487, font2, 0)

        Font.Draw ("QUIT", 11, 7, font3, 7)
        Draw.Box (0, 0, 95, 45, 7) % quit box

        mousewhere (j, k, button)  % if you want to quit, button
        exit when j > 0 and j < 150 and k > 0 and k < 50 and button = 1

        Draw.FillBox (25, 35, 727, 105, 0) % surrounds bottom letters
        Draw.Box (25, 35, 727, 105, 7)

        % surrounds man
        Draw.FillBox (500, 95, 705, 440, 0)
        Draw.Box (500, 95, 705, 440, 7)

        Draw.ThickLine (680, 140, 680, 430, 10, 7)  % hanging platform
        Draw.ThickLine (545, 430, 681, 430, 10, 7)
        Draw.ThickLine (600, 401, 600, 430, 3, 7)
        Draw.ThickLine (650, 140, 695, 140, 10, 7)

        for z : 1 .. 26 % draws black letters at bottom of screen
            Font.Draw (alpha (z), 1 + 27 * z, 60, font1, 7)
        end for

        c := length (word)

        for b : 1 .. c % draws enough lines for letters of word
            Draw.ThickLine (84 + b * 30, 160, 110 + b * 30, 160, 2, 7)
        end for

        loop
            Draw.FillBox (25, 445, 149, 415, 0)   % box around 'guess a letter'
            Draw.Box (25, 445, 149, 415, 7)

            locate (8, 5)
            put "Guess a letter" ..

            loop
                mousewhere (j, k, button) % if you want to quit
                exit when j > 0 and j < 150 and k > 0 and k < 50 and button = 1

                locate (8, 21)
                getch (guess) %  player's guess, only one letter


                guess := Str.Lower (guess) % makes guess lower case

  ''              if d > 0 then
                    for i : 1 .. d
                        '''if guess = trash (d) then'''
                            continue := 0
                        else
                            continue := 1
                            guess := trash (d)''                               % guessed letter goes into trash
                        end if
                    end for
                end if

                exit when continue = 1
                put "You already guessed that letter. Please guess again."

            end loop


            % if guesss is correct, places letter in space
            if guess = word (1) then
                Font.Draw (guess, 120, 165, font1, 7)
                right := right + 1
            end if
            if guess = word (2) then
                Font.Draw (guess, 150, 165, font1, 7)
                right := right + 1
            end if
            if guess = word (3) then
                Font.Draw (guess, 180, 165, font1, 7)
                right := right + 1
            end if

            if c >= 4 then
                if guess = word (4) then
                    Font.Draw (guess, 210, 165, font1, 7)
                    right := right + 1
                end if
            end if
            if c >= 5 then
                if guess = word (5) then
                    Font.Draw (guess, 240, 165, font1, 7)
                    right := right + 1
                end if
            end if
            if c >= 6 then
                if guess = word (6) then
                    Font.Draw (guess, 270, 165, font1, 7)
                    right := right + 1
                end if
            end if
            if c >= 7 then
                if guess = word (7) then
                    Font.Draw (guess, 300, 165, font1, 7)
                    right := right + 1
                end if
            end if
            if c >= 8 then
                if guess = word (8) then
                    Font.Draw (guess, 330, 165, font1, 7)
                    right := right + 1
                end if
            end if
            if c >= 9 then
                if guess = word (9) then
                    Font.Draw (guess, 360, 165, font1, 7)
                    right := right + 1
                end if
            end if
            if c >= 10 then
                if guess = word (10) then
                    Font.Draw (guess, 390, 165, font1, 7)
                end if
                right := right + 1
            end if
            if c >= 11 then
                if guess = word (11) then
                    Font.Draw (guess, 410, 165, font1, 7)
                    right := right + 1
                end if
            end if

            if c = 11 then
                if guess not= word (1) and guess not= word (2) and guess not= word (3) and guess
                        not= word (4) and guess not= word (5) and guess not= word (6) and guess
                        not= word (7) and guess not= word (8) and guess not= word (9) and guess
                        not= word (10) and guess not= word (11) then
                    wrong := wrong + 1
                end if
            end if

            if c = 10 then
                if guess not= word (1) and guess not= word (2) and guess not= word (3) and guess
                        not= word (4) and guess not= word (5) and guess not= word (6) and guess not= word (7)
                        and guess not= word (8) and guess not= word (9) and guess not= word (10) then
                    wrong := wrong + 1
                end if
            end if

            if c = 9 then
                if guess not= word (1) and guess not= word (2) and guess not= word (3)
                        and guess not= word (4) and guess not= word (5) and guess not= word (6)
                        and guess not= word (7) and guess not= word (8) and guess not= word (9) then
                    wrong := wrong + 1
                end if
            end if

            if c = 8 then
                if guess not= word (1) and guess not= word (2) and guess not= word (3)
                        and guess not= word (4) and guess not= word (5) and guess not=
                        word (6) and guess not= word (7) and guess not= word (8)
                        then
                    wrong := wrong + 1
                end if
            end if

            if c = 7 then
                if guess not= word (1) and guess not= word (2) and guess not= word (3)
                        and guess not= word (4) and guess not= word (5) and guess not= word (6)
                        and guess not= word (7) then
                    wrong := wrong + 1
                end if
            end if

            if c = 6 then
                if guess not= word (1) and guess not= word (2) and guess not= word (3)
                        and guess not= word (4) and guess not= word (5) and guess not= word (6) then
                    wrong := wrong + 1
                end if
            end if

            if c = 5 then
                if guess not= word (1) and guess not= word (2) and guess not= word (3)
                        and guess not= word (4) and guess not= word (5) then
                    wrong := wrong + 1
                end if
            end if

            if c = 4 then
                if guess not= word (1) and guess not= word (2) and guess not= word (3)
                        and guess not= word (4) then
                    wrong := wrong + 1
                end if
            end if

            if c = 3 then
                if guess not= word (1) and guess not= word (2) and guess not= word (3) then
                    wrong := wrong + 1
                end if
            end if

            if wrong = 1 then
                var pictureapplesad : int := Pic.FileNew ("applesad.jpg")  % head
                %Pic.Draw (pictureapplesad, 561, 340, picCopy)
            elsif wrong = 2 then
                Draw.ThickLine (600, 340, 600, 220, 3, 111)             % body
            elsif wrong = 3 then
                Draw.ThickLine (600, 320, 640, 270, 3, 111)             % right arm
            elsif wrong = 4 then
                Draw.ThickLine (600, 320, 560, 270, 3, 111)             % left arm
            elsif wrong = 5 then
                Draw.ThickLine (600, 220, 640, 160, 3, 111)             % right leg
            elsif wrong = 6 then
                Draw.ThickLine (600, 220, 560, 160, 3, 111)             % left leg
            else
            end if
            put "right ", right ..

            locate (28, 64)
            put "You have ", wrong, " wrong guesses." ..

            guess := Str.Upper (guess)

            for x : 1 .. 26        % erases letter from bottom of screen
                if guess = alpha (x) then
                    Font.Draw (alpha (x), 1 + 27 * x, 60, font1, 0)
                end if
            end for

            if right = c then   % if number of correct letters = number of letters in word
                Draw.FillBox (95, 295, 245, 330, 7)
                Font.Draw ("You Win!", 100, 300, font4, 0)
                Music.PlayFile ("clap.mp3")
                delay (1000)
                exit
            end if
            d := d + 1


            mousewhere (j, k, button)
            exit when j > 0 and j < 280 and k > 0 and k < 250 and button = 1
            exit when wrong = 6
        end loop

        % exit option at bottom of screen
        mousewhere (j, k, button)
        exit when j > 0 and j < 180 and k > 0 and k < 150 and button = 1



        if wrong = 6 then   % if they get 6 wrong guesses, they lose
            locate (12, 10)
            put "The word was: " ..  % shows correct word
            Font.Draw (word, 180, 360, font3, 7)
        end if
        exit when wrong = 6 or right = c
    end loop

    close : file1

end game


loop
    wrong := 0 % number of wrong guesses
    right := 0 % number of right guesses

    intro
    game
    put "Would you like to play again? Y/N"
    get playagain
    if playagain = "y" or playagain = "Y" then
        cls
    elsif playagain = "n" or playagain = "N" then
        exit
    end if

end loop

How do you find the highest and lowest number from a list of numbers given in Turing (programming)?[edit]

Here is the question: Prompt the user to input test marks. Find the average and highest and lowest marks.

The average was easy to find but I have on idea how to get the highest and lowest marks. Our (Gr. 10) Turing class so far has covered loops, for loops, if statements, variable types: string, real, int, and other basic things.

Anyone have any idea how to solve this, please? Thanks.